forked from OSchip/llvm-project
[ARM64] Port over the PostEncoderMethod from AArch64 for exclusive loads and stores, so the unused register fields are set to all-ones canonically but are recognised with any value.
llvm-svn: 205874
This commit is contained in:
parent
4925be9b56
commit
bc35b1f138
|
@ -2901,6 +2901,18 @@ class StorePairNoAlloc<bits<2> opc, bit V, RegisterClass regtype,
|
||||||
// True exclusive operations write to and/or read from the system's exclusive
|
// True exclusive operations write to and/or read from the system's exclusive
|
||||||
// monitors, which as far as a compiler is concerned can be modelled as a
|
// monitors, which as far as a compiler is concerned can be modelled as a
|
||||||
// random shared memory address. Hence LoadExclusive mayStore.
|
// random shared memory address. Hence LoadExclusive mayStore.
|
||||||
|
//
|
||||||
|
// Since these instructions have the undefined register bits set to 1 in
|
||||||
|
// their canonical form, we need a post encoder method to set those bits
|
||||||
|
// to 1 when encoding these instructions. We do this using the
|
||||||
|
// fixLoadStoreExclusive function. This function has template parameters:
|
||||||
|
//
|
||||||
|
// fixLoadStoreExclusive<int hasRs, int hasRt2>
|
||||||
|
//
|
||||||
|
// hasRs indicates that the instruction uses the Rs field, so we won't set
|
||||||
|
// it to 1 (and the same for Rt2). We don't need template parameters for
|
||||||
|
// the other register fields since Rt and Rn are always used.
|
||||||
|
//
|
||||||
let hasSideEffects = 1, mayLoad = 1, mayStore = 1 in
|
let hasSideEffects = 1, mayLoad = 1, mayStore = 1 in
|
||||||
class BaseLoadStoreExclusive<bits<2> sz, bit o2, bit L, bit o1, bit o0,
|
class BaseLoadStoreExclusive<bits<2> sz, bit o2, bit L, bit o1, bit o0,
|
||||||
dag oops, dag iops, string asm, string operands>
|
dag oops, dag iops, string asm, string operands>
|
||||||
|
@ -2921,10 +2933,10 @@ class LoadStoreExclusiveSimple<bits<2> sz, bit o2, bit L, bit o1, bit o0,
|
||||||
: BaseLoadStoreExclusive<sz, o2, L, o1, o0, oops, iops, asm, operands> {
|
: BaseLoadStoreExclusive<sz, o2, L, o1, o0, oops, iops, asm, operands> {
|
||||||
bits<5> reg;
|
bits<5> reg;
|
||||||
bits<5> base;
|
bits<5> base;
|
||||||
let Inst{20-16} = 0b11111;
|
|
||||||
let Inst{14-10} = 0b11111;
|
|
||||||
let Inst{9-5} = base;
|
let Inst{9-5} = base;
|
||||||
let Inst{4-0} = reg;
|
let Inst{4-0} = reg;
|
||||||
|
|
||||||
|
let PostEncoderMethod = "fixLoadStoreExclusive<0,0>";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simple load acquires don't set the exclusive monitor
|
// Simple load acquires don't set the exclusive monitor
|
||||||
|
@ -2951,10 +2963,11 @@ class LoadExclusivePair<bits<2> sz, bit o2, bit L, bit o1, bit o0,
|
||||||
bits<5> dst1;
|
bits<5> dst1;
|
||||||
bits<5> dst2;
|
bits<5> dst2;
|
||||||
bits<5> base;
|
bits<5> base;
|
||||||
let Inst{20-16} = 0b11111;
|
|
||||||
let Inst{14-10} = dst2;
|
let Inst{14-10} = dst2;
|
||||||
let Inst{9-5} = base;
|
let Inst{9-5} = base;
|
||||||
let Inst{4-0} = dst1;
|
let Inst{4-0} = dst1;
|
||||||
|
|
||||||
|
let PostEncoderMethod = "fixLoadStoreExclusive<0,1>";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simple store release operations do not check the exclusive monitor.
|
// Simple store release operations do not check the exclusive monitor.
|
||||||
|
@ -2977,11 +2990,11 @@ class StoreExclusive<bits<2> sz, bit o2, bit L, bit o1, bit o0,
|
||||||
bits<5> reg;
|
bits<5> reg;
|
||||||
bits<5> base;
|
bits<5> base;
|
||||||
let Inst{20-16} = status;
|
let Inst{20-16} = status;
|
||||||
let Inst{14-10} = 0b11111;
|
|
||||||
let Inst{9-5} = base;
|
let Inst{9-5} = base;
|
||||||
let Inst{4-0} = reg;
|
let Inst{4-0} = reg;
|
||||||
|
|
||||||
let Constraints = "@earlyclobber $Ws";
|
let Constraints = "@earlyclobber $Ws";
|
||||||
|
let PostEncoderMethod = "fixLoadStoreExclusive<1,0>";
|
||||||
}
|
}
|
||||||
|
|
||||||
class StoreExclusivePair<bits<2> sz, bit o2, bit L, bit o1, bit o0,
|
class StoreExclusivePair<bits<2> sz, bit o2, bit L, bit o1, bit o0,
|
||||||
|
|
|
@ -176,6 +176,11 @@ public:
|
||||||
void EncodeInstruction(const MCInst &MI, raw_ostream &OS,
|
void EncodeInstruction(const MCInst &MI, raw_ostream &OS,
|
||||||
SmallVectorImpl<MCFixup> &Fixups,
|
SmallVectorImpl<MCFixup> &Fixups,
|
||||||
const MCSubtargetInfo &STI) const;
|
const MCSubtargetInfo &STI) const;
|
||||||
|
|
||||||
|
template<int hasRs, int hasRt2> unsigned
|
||||||
|
fixLoadStoreExclusive(const MCInst &MI, unsigned EncodedValue,
|
||||||
|
const MCSubtargetInfo &STI) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end anonymous namespace
|
} // end anonymous namespace
|
||||||
|
@ -560,4 +565,14 @@ void ARM64MCCodeEmitter::EncodeInstruction(const MCInst &MI, raw_ostream &OS,
|
||||||
++MCNumEmitted; // Keep track of the # of mi's emitted.
|
++MCNumEmitted; // Keep track of the # of mi's emitted.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<int hasRs, int hasRt2> unsigned
|
||||||
|
ARM64MCCodeEmitter::fixLoadStoreExclusive(const MCInst &MI,
|
||||||
|
unsigned EncodedValue,
|
||||||
|
const MCSubtargetInfo &STI) const {
|
||||||
|
if (!hasRs) EncodedValue |= 0x001F0000;
|
||||||
|
if (!hasRt2) EncodedValue |= 0x00007C00;
|
||||||
|
|
||||||
|
return EncodedValue;
|
||||||
|
}
|
||||||
|
|
||||||
#include "ARM64GenMCCodeEmitter.inc"
|
#include "ARM64GenMCCodeEmitter.inc"
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
# RUN: llvm-mc -triple arm64-apple-darwin --disassemble < %s | FileCheck %s
|
||||||
|
|
||||||
|
0x00 0x08 0x00 0xc8
|
||||||
|
|
||||||
|
# CHECK: stxr w0, x0, [x0]
|
Loading…
Reference in New Issue