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/X86/sgx-encoding.s =================================================================== --- test/MC/X86/sgx-encoding.s +++ test/MC/X86/sgx-encoding.s @@ -1,4 +1,5 @@ // RUN: llvm-mc -triple x86_64-unknown-unknown --show-encoding %s | FileCheck %s +// RUN: llvm-mc -triple i386 --show-encoding %s | FileCheck %s // CHECK: encls // CHECK: encoding: [0x0f,0x01,0xcf] @@ -7,3 +8,7 @@ // CHECK: enclu // CHECK: encoding: [0x0f,0x01,0xd7] enclu + +// CHECK: enclv +// CHECK: encoding: [0x0f,0x01,0xc0] + enclv