def macroop ADD_LOCKED_M_I
{
limm t2, imm
+ mfence
ldstl t1, seg, sib, disp
add t1, t1, t2, flags=(OF,SF,ZF,AF,PF,CF)
stul t1, seg, sib, disp
+ mfence
};
def macroop ADD_LOCKED_P_I
{
rdip t7
limm t2, imm
+ mfence
ldstl t1, seg, riprel, disp
add t1, t1, t2, flags=(OF,SF,ZF,AF,PF,CF)
stul t1, seg, riprel, disp
+ mfence
};
def macroop ADD_M_R
def macroop ADD_LOCKED_M_R
{
+ mfence
ldstl t1, seg, sib, disp
add t1, t1, reg, flags=(OF,SF,ZF,AF,PF,CF)
stul t1, seg, sib, disp
+ mfence
};
def macroop ADD_LOCKED_P_R
{
rdip t7
+ mfence
ldstl t1, seg, riprel, disp
add t1, t1, reg, flags=(OF,SF,ZF,AF,PF,CF)
stul t1, seg, riprel, disp
+ mfence
};
def macroop ADD_R_M
def macroop SUB_LOCKED_M_I
{
limm t2, imm
+ mfence
ldstl t1, seg, sib, disp
sub t1, t1, t2, flags=(OF,SF,ZF,AF,PF,CF)
stul t1, seg, sib, disp
+ mfence
};
def macroop SUB_LOCKED_P_I
{
rdip t7
limm t2, imm
+ mfence
ldstl t1, seg, riprel, disp
sub t1, t1, t2, flags=(OF,SF,ZF,AF,PF,CF)
stul t1, seg, riprel, disp
+ mfence
};
def macroop SUB_M_R
def macroop SUB_LOCKED_M_R
{
+ mfence
ldstl t1, seg, sib, disp
sub t1, t1, reg, flags=(OF,SF,ZF,AF,PF,CF)
stul t1, seg, sib, disp
+ mfence
};
def macroop SUB_LOCKED_P_R
{
rdip t7
+ mfence
ldstl t1, seg, riprel, disp
sub t1, t1, reg, flags=(OF,SF,ZF,AF,PF,CF)
stul t1, seg, riprel, disp
+ mfence
};
def macroop ADC_R_R
def macroop ADC_LOCKED_M_I
{
limm t2, imm
+ mfence
ldstl t1, seg, sib, disp
adc t1, t1, t2, flags=(OF,SF,ZF,AF,PF,CF)
stul t1, seg, sib, disp
+ mfence
};
def macroop ADC_LOCKED_P_I
{
rdip t7
limm t2, imm
+ mfence
ldstl t1, seg, riprel, disp
adc t1, t1, t2, flags=(OF,SF,ZF,AF,PF,CF)
stul t1, seg, riprel, disp
+ mfence
};
def macroop ADC_M_R
def macroop ADC_LOCKED_M_R
{
+ mfence
ldstl t1, seg, sib, disp
adc t1, t1, reg, flags=(OF,SF,ZF,AF,PF,CF)
stul t1, seg, sib, disp
+ mfence
};
def macroop ADC_LOCKED_P_R
{
rdip t7
+ mfence
ldstl t1, seg, riprel, disp
adc t1, t1, reg, flags=(OF,SF,ZF,AF,PF,CF)
stul t1, seg, riprel, disp
+ mfence
};
def macroop ADC_R_M
def macroop SBB_LOCKED_M_I
{
limm t2, imm
+ mfence
ldstl t1, seg, sib, disp
sbb t1, t1, t2, flags=(OF,SF,ZF,AF,PF,CF)
stul t1, seg, sib, disp
+ mfence
};
def macroop SBB_LOCKED_P_I
{
rdip t7
limm t2, imm
+ mfence
ldstl t1, seg, riprel, disp
sbb t1, t1, t2, flags=(OF,SF,ZF,AF,PF,CF)
stul t1, seg, riprel, disp
+ mfence
};
def macroop SBB_M_R
def macroop SBB_LOCKED_M_R
{
+ mfence
ldstl t1, seg, sib, disp
sbb t1, t1, reg, flags=(OF,SF,ZF,AF,PF,CF)
stul t1, seg, sib, disp
+ mfence
};
def macroop SBB_LOCKED_P_R
{
rdip t7
+ mfence
ldstl t1, seg, riprel, disp
sbb t1, t1, reg, flags=(OF,SF,ZF,AF,PF,CF)
stul t1, seg, riprel, disp
+ mfence
};
def macroop NEG_R
def macroop NEG_LOCKED_M
{
+ mfence
ldstl t1, seg, sib, disp
sub t1, t0, t1, flags=(CF,OF,SF,ZF,AF,PF)
stul t1, seg, sib, disp
+ mfence
};
def macroop NEG_LOCKED_P
{
rdip t7
+ mfence
ldstl t1, seg, riprel, disp
sub t1, t0, t1, flags=(CF,OF,SF,ZF,AF,PF)
stul t1, seg, riprel, disp
+ mfence
};
'''
def macroop INC_LOCKED_M
{
+ mfence
ldstl t1, seg, sib, disp
addi t1, t1, 1, flags=(OF, SF, ZF, AF, PF)
stul t1, seg, sib, disp
+ mfence
};
def macroop INC_LOCKED_P
{
rdip t7
+ mfence
ldstl t1, seg, riprel, disp
addi t1, t1, 1, flags=(OF, SF, ZF, AF, PF)
stul t1, seg, riprel, disp
+ mfence
};
def macroop DEC_R
def macroop DEC_LOCKED_M
{
+ mfence
ldstl t1, seg, sib, disp
subi t1, t1, 1, flags=(OF, SF, ZF, AF, PF)
stul t1, seg, sib, disp
+ mfence
};
def macroop DEC_LOCKED_P
{
rdip t7
+ mfence
ldstl t1, seg, riprel, disp
subi t1, t1, 1, flags=(OF, SF, ZF, AF, PF)
stul t1, seg, riprel, disp
+ mfence
};
'''
limm t1, imm, dataSize=asz
limm t4, 1
roli t4, t4, imm
+ mfence
ldstl t1, seg, sib, disp
sexti t0, t1, imm, flags=(CF,)
xor t1, t1, t4
stul t1, seg, sib, disp
+ mfence
};
def macroop BTC_LOCKED_P_I {
limm t1, imm, dataSize=asz
limm t4, 1
roli t4, t4, imm
+ mfence
ldstl t1, seg, riprel, disp
sexti t0, t1, imm, flags=(CF,)
xor t1, t1, t4
stul t1, seg, riprel, disp
+ mfence
};
def macroop BTC_R_R {
lea t3, flatseg, [dsz, t3, base], dataSize=asz
limm t4, 1
rol t4, t4, reg
+ mfence
ldstl t1, seg, [scale, index, t3], disp
sext t0, t1, reg, flags=(CF,)
xor t1, t1, t4
stul t1, seg, [scale, index, t3], disp
+ mfence
};
def macroop BTC_LOCKED_P_R {
srai t3, t2, ldsz, dataSize=asz
limm t4, 1
rol t4, t4, reg
+ mfence
ldstl t1, seg, [dsz, t3, t7], disp
sext t0, t1, reg, flags=(CF,)
xor t1, t1, t4
stul t1, seg, [dsz, t3, t7], disp
+ mfence
};
def macroop BTR_R_I {
limm t1, imm, dataSize=asz
limm t4, "(uint64_t(-(2ULL)))"
roli t4, t4, imm
+ mfence
ldstl t1, seg, sib, disp
sexti t0, t1, imm, flags=(CF,)
and t1, t1, t4
stul t1, seg, sib, disp
+ mfence
};
def macroop BTR_LOCKED_P_I {
limm t1, imm, dataSize=asz
limm t4, "(uint64_t(-(2ULL)))"
roli t4, t4, imm
+ mfence
ldstl t1, seg, riprel, disp
sexti t0, t1, imm, flags=(CF,)
and t1, t1, t4
stul t1, seg, riprel, disp
+ mfence
};
def macroop BTR_R_R {
lea t3, flatseg, [dsz, t3, base], dataSize=asz
limm t4, "(uint64_t(-(2ULL)))"
rol t4, t4, reg
+ mfence
ldstl t1, seg, [scale, index, t3], disp
sext t0, t1, reg, flags=(CF,)
and t1, t1, t4
stul t1, seg, [scale, index, t3], disp
+ mfence
};
def macroop BTR_LOCKED_P_R {
srai t3, t2, ldsz, dataSize=asz
limm t4, "(uint64_t(-(2ULL)))"
rol t4, t4, reg
+ mfence
ldstl t1, seg, [dsz, t3, t7], disp
sext t0, t1, reg, flags=(CF,)
and t1, t1, t4
stul t1, seg, [dsz, t3, t7], disp
+ mfence
};
def macroop BTS_R_I {
limm t1, imm, dataSize=asz
limm t4, 1
roli t4, t4, imm
+ mfence
ldstl t1, seg, sib, disp
sexti t0, t1, imm, flags=(CF,)
or t1, t1, t4
stul t1, seg, sib, disp
+ mfence
};
def macroop BTS_LOCKED_P_I {
limm t1, imm, dataSize=asz
limm t4, 1
roli t4, t4, imm
+ mfence
ldstl t1, seg, riprel, disp
sexti t0, t1, imm, flags=(CF,)
or t1, t1, t4
stul t1, seg, riprel, disp
+ mfence
};
def macroop BTS_R_R {
lea t3, flatseg, [dsz, t3, base], dataSize=asz
limm t4, 1
rol t4, t4, reg
+ mfence
ldstl t1, seg, [scale, index, t3], disp
sext t0, t1, reg, flags=(CF,)
or t1, t1, t4
stul t1, seg, [scale, index, t3], disp
+ mfence
};
def macroop BTS_LOCKED_P_R {
lea t3, flatseg, [dsz, t3, base], dataSize=asz
limm t4, 1
rol t4, t4, reg
+ mfence
ldstl t1, seg, [1, t3, t7], disp
sext t0, t1, reg, flags=(CF,)
or t1, t1, t4
stul t1, seg, [1, t3, t7], disp
+ mfence
};
'''
def macroop XCHG_R_M
{
+ mfence
ldstl t1, seg, sib, disp
stul reg, seg, sib, disp
+ mfence
mov reg, reg, t1
};
def macroop XCHG_R_P
{
rdip t7
+ mfence
ldstl t1, seg, riprel, disp
stul reg, seg, riprel, disp
+ mfence
mov reg, reg, t1
};
def macroop XCHG_M_R
{
+ mfence
ldstl t1, seg, sib, disp
stul reg, seg, sib, disp
+ mfence
mov reg, reg, t1
};
def macroop XCHG_P_R
{
rdip t7
+ mfence
ldstl t1, seg, riprel, disp
stul reg, seg, riprel, disp
+ mfence
mov reg, reg, t1
};
def macroop XCHG_LOCKED_M_R
{
+ mfence
ldstl t1, seg, sib, disp
stul reg, seg, sib, disp
+ mfence
mov reg, reg, t1
};
def macroop XCHG_LOCKED_P_R
{
rdip t7
+ mfence
ldstl t1, seg, riprel, disp
stul reg, seg, riprel, disp
+ mfence
mov reg, reg, t1
};
'''
def macroop OR_LOCKED_M_I
{
limm t2, imm
+ mfence
ldstl t1, seg, sib, disp
or t1, t1, t2, flags=(OF,SF,ZF,PF,CF)
stul t1, seg, sib, disp
+ mfence
};
def macroop OR_LOCKED_P_I
{
limm t2, imm
rdip t7
+ mfence
ldstl t1, seg, riprel, disp
or t1, t1, t2, flags=(OF,SF,ZF,PF,CF)
stul t1, seg, riprel, disp
+ mfence
};
def macroop OR_M_R
def macroop OR_LOCKED_M_R
{
+ mfence
ldstl t1, seg, sib, disp
or t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
stul t1, seg, sib, disp
+ mfence
};
def macroop OR_LOCKED_P_R
{
rdip t7
+ mfence
ldstl t1, seg, riprel, disp
or t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
stul t1, seg, riprel, disp
+ mfence
};
def macroop OR_R_M
def macroop XOR_LOCKED_M_I
{
limm t2, imm
+ mfence
ldstl t1, seg, sib, disp
xor t1, t1, t2, flags=(OF,SF,ZF,PF,CF)
stul t1, seg, sib, disp
+ mfence
};
def macroop XOR_LOCKED_P_I
{
limm t2, imm
rdip t7
+ mfence
ldstl t1, seg, riprel, disp
xor t1, t1, t2, flags=(OF,SF,ZF,PF,CF)
stul t1, seg, riprel, disp
+ mfence
};
def macroop XOR_M_R
def macroop XOR_LOCKED_M_R
{
+ mfence
ldstl t1, seg, sib, disp
xor t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
stul t1, seg, sib, disp
+ mfence
};
def macroop XOR_LOCKED_P_R
{
rdip t7
+ mfence
ldstl t1, seg, riprel, disp
xor t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
stul t1, seg, riprel, disp
+ mfence
};
def macroop XOR_R_M
def macroop AND_LOCKED_M_I
{
+ mfence
ldstl t2, seg, sib, disp
limm t1, imm
and t2, t2, t1, flags=(OF,SF,ZF,PF,CF)
stul t2, seg, sib, disp
+ mfence
};
def macroop AND_LOCKED_P_I
{
rdip t7
+ mfence
ldstl t2, seg, riprel, disp
limm t1, imm
and t2, t2, t1, flags=(OF,SF,ZF,PF,CF)
stul t2, seg, riprel, disp
+ mfence
};
def macroop AND_M_R
def macroop AND_LOCKED_M_R
{
+ mfence
ldstl t1, seg, sib, disp
and t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
stul t1, seg, sib, disp
+ mfence
};
def macroop AND_LOCKED_P_R
{
rdip t7
+ mfence
ldstl t1, seg, riprel, disp
and t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
stul t1, seg, riprel, disp
+ mfence
};
def macroop NOT_R
def macroop NOT_LOCKED_M
{
limm t1, -1
+ mfence
ldstl t2, seg, sib, disp
xor t2, t2, t1
stul t2, seg, sib, disp
+ mfence
};
def macroop NOT_LOCKED_P
{
limm t1, -1
rdip t7
+ mfence
ldstl t2, seg, riprel, disp
xor t2, t2, t1
stul t2, seg, riprel, disp
+ mfence
};
'''
};
def macroop CMPXCHG_LOCKED_M_R {
+ mfence
ldstl t1, seg, sib, disp
sub t0, rax, t1, flags=(OF, SF, ZF, AF, PF, CF)
mov t1, t1, reg, flags=(CZF,)
stul t1, seg, sib, disp
+ mfence
mov rax, rax, t1, flags=(nCZF,)
};
def macroop CMPXCHG_LOCKED_P_R {
rdip t7
+ mfence
ldstl t1, seg, riprel, disp
sub t0, rax, t1, flags=(OF, SF, ZF, AF, PF, CF)
mov t1, t1, reg, flags=(CZF,)
stul t1, seg, riprel, disp
+ mfence
mov rax, rax, t1, flags=(nCZF,)
};
};
def macroop XADD_LOCKED_M_R {
+ mfence
ldstl t1, seg, sib, disp
add t2, t1, reg, flags=(OF,SF,ZF,AF,PF,CF)
stul t2, seg, sib, disp
+ mfence
mov reg, reg, t1
};
def macroop XADD_LOCKED_P_R {
rdip t7
+ mfence
ldstl t1, seg, riprel, disp
add t2, t1, reg, flags=(OF,SF,ZF,AF,PF,CF)
stul t2, seg, riprel, disp
+ mfence
mov reg, reg, t1
};
// Copyright (c) 2007-2008 The Hewlett-Packard Development Company
+// Copyright (c) 2011 Mark D. Hill and David A. Wood
// All rights reserved.
//
// The license below extends only to copyright in the software and shall
microopClasses["halt"] = Halt
}};
+
+def template MicroFenceOpDeclare {{
+ class %(class_name)s : public X86ISA::X86MicroopBase
+ {
+ public:
+ %(class_name)s(ExtMachInst _machInst,
+ const char * instMnem,
+ uint64_t setFlags);
+
+ %(BasicExecDeclare)s
+ };
+}};
+
+def template MicroFenceOpConstructor {{
+ inline %(class_name)s::%(class_name)s(
+ ExtMachInst machInst, const char * instMnem, uint64_t setFlags) :
+ %(base_class)s(machInst, "%(mnemonic)s", instMnem,
+ setFlags, %(op_class)s)
+ {
+ %(constructor)s;
+ }
+}};
+
+let {{
+ class MfenceOp(X86Microop):
+ def __init__(self):
+ self.className = "Mfence"
+ self.mnemonic = "mfence"
+ self.instFlags = "| (1ULL << StaticInst::IsMemBarrier)"
+
+ def getAllocator(self, microFlags):
+ allocString = '''
+ (StaticInstPtr)(new %(class_name)s(machInst,
+ macrocodeBlock, %(flags)s))
+ '''
+ allocator = allocString % {
+ "class_name" : self.className,
+ "mnemonic" : self.mnemonic,
+ "flags" : self.microFlagsText(microFlags) + self.instFlags}
+ return allocator
+
+ microopClasses["mfence"] = MfenceOp
+}};
+
+let {{
+ # Build up the all register version of this micro op
+ iop = InstObjParams("mfence", "Mfence", 'X86MicroopBase',
+ {"code" : ""})
+ header_output += MicroFenceOpDeclare.subst(iop)
+ decoder_output += MicroFenceOpConstructor.subst(iop)
+ exec_output += BasicExecute.subst(iop)
+}};