Index: lib/Target/X86/X86InstrInfo.td =================================================================== --- lib/Target/X86/X86InstrInfo.td +++ lib/Target/X86/X86InstrInfo.td @@ -881,6 +881,7 @@ def HasRTM : Predicate<"Subtarget->hasRTM()">; def HasADX : Predicate<"Subtarget->hasADX()">; def HasSHA : Predicate<"Subtarget->hasSHA()">; +def HasSGX : Predicate<"Subtarget->hasSGX()">; def HasPRFCHW : Predicate<"Subtarget->hasPRFCHW()">; def HasRDSEED : Predicate<"Subtarget->hasRDSEED()">; def HasSSEPrefetch : Predicate<"Subtarget->hasSSEPrefetch()">; Index: lib/Target/X86/X86InstrSGX.td =================================================================== --- lib/Target/X86/X86InstrSGX.td +++ lib/Target/X86/X86InstrSGX.td @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// // SGX instructions -let SchedRW = [WriteSystem] in { +let SchedRW = [WriteSystem], Predicates = [HasSGX] in { // ENCLS - Execute an Enclave System Function of Specified Leaf Number def ENCLS : I<0x01, MRM_CF, (outs), (ins), "encls", []>, TB; @@ -23,4 +23,8 @@ // ENCLU - Execute an Enclave User Function of Specified Leaf Number def ENCLU : I<0x01, MRM_D7, (outs), (ins), "enclu", []>, TB; + +// ENCLV - Execute an Enclave VMM Function of Specified Leaf Number +def ENCLV : I<0x01, MRM_C0, (outs), (ins), + "enclv", []>, TB; } // SchedRW Index: lib/Target/X86/X86Subtarget.h =================================================================== --- lib/Target/X86/X86Subtarget.h +++ lib/Target/X86/X86Subtarget.h @@ -640,6 +640,7 @@ bool hasWBNOINVD() const { return HasWBNOINVD; } bool hasRDPID() const { return HasRDPID; } bool hasWAITPKG() const { return HasWAITPKG; } + bool hasSGX() const { return HasSGX; } bool useRetpoline() const { return UseRetpoline; } bool useRetpolineExternalThunk() const { return UseRetpolineExternalThunk; } Index: test/MC/Disassembler/X86/x86-32.txt =================================================================== --- test/MC/Disassembler/X86/x86-32.txt +++ test/MC/Disassembler/X86/x86-32.txt @@ -871,3 +871,12 @@ #CHECK: movdir64b (%si), %ax 0x67 0x66 0x0f 0x38 0xf8 0x04 + +#CHECK: encls +0x0f 0x01 0xcf + +#CHECK: enclu +0x0f 0x01 0xd7 + +#CHECK: enclv +0x0f 0x01 0xc0 Index: test/MC/Disassembler/X86/x86-64.txt =================================================================== --- test/MC/Disassembler/X86/x86-64.txt +++ test/MC/Disassembler/X86/x86-64.txt @@ -564,3 +564,12 @@ #CHECK: movdir64b 485498096, %eax 0x67 0x66 0x0f 0x38 0xf8 0x04 0x25 0xf0 0x1c 0xf0 0x1c + +#CHECK: encls +0x0f 0x01 0xcf + +#CHECK: enclu +0x0f 0x01 0xd7 + +#CHECK: enclv +0x0f 0x01 0xc0 Index: test/MC/X86/SGX-32.s =================================================================== --- test/MC/X86/SGX-32.s +++ /dev/null @@ -1,10 +0,0 @@ -// RUN: llvm-mc -triple i386-unknown-unknown --show-encoding %s | FileCheck %s - -// CHECK: encls -// CHECK: encoding: [0x0f,0x01,0xcf] -encls - -// CHECK: enclu -// CHECK: encoding: [0x0f,0x01,0xd7] -enclu - Index: test/MC/X86/SGX-64.s =================================================================== --- test/MC/X86/SGX-64.s +++ /dev/null @@ -1,10 +0,0 @@ -// RUN: llvm-mc -triple x86_64-unknown-unknown --show-encoding %s | FileCheck %s - -// CHECK: encls -// CHECK: encoding: [0x0f,0x01,0xcf] -encls - -// CHECK: enclu -// CHECK: encoding: [0x0f,0x01,0xd7] -enclu - Index: test/MC/X86/sgx-encoding.s =================================================================== --- test/MC/X86/sgx-encoding.s +++ /dev/null @@ -1,9 +0,0 @@ -// RUN: llvm-mc -triple x86_64-unknown-unknown --show-encoding %s | FileCheck %s - -// CHECK: encls -// CHECK: encoding: [0x0f,0x01,0xcf] - encls - -// CHECK: enclu -// CHECK: encoding: [0x0f,0x01,0xd7] - enclu Index: test/MC/X86/x86-32-coverage.s =================================================================== --- test/MC/X86/x86-32-coverage.s +++ test/MC/X86/x86-32-coverage.s @@ -10792,3 +10792,15 @@ // CHECK: movdir64b (%si), %ax // CHECK: # encoding: [0x67,0x66,0x0f,0x38,0xf8,0x04] movdir64b (%si), %ax + +// CHECK: encls +// CHECK: encoding: [0x0f,0x01,0xcf] +encls + +// CHECK: enclu +// CHECK: encoding: [0x0f,0x01,0xd7] +enclu + +// CHECK: enclv +// CHECK: encoding: [0x0f,0x01,0xc0] +enclv Index: test/MC/X86/x86-64.s =================================================================== --- test/MC/X86/x86-64.s +++ test/MC/X86/x86-64.s @@ -1619,6 +1619,18 @@ // CHECK: # encoding: [0x66,0x44,0x0f,0x38,0xf8,0x3a] movdir64b (%rdx), %r15 +// CHECK: encls +// CHECK: encoding: [0x0f,0x01,0xcf] +encls + +// CHECK: enclu +// CHECK: encoding: [0x0f,0x01,0xd7] +enclu + +// CHECK: enclv +// CHECK: encoding: [0x0f,0x01,0xc0] +enclv + // __asm __volatile( // "pushf \n\t" // "popf \n\t"