mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-03 13:31:05 +00:00
Expand Op0Mask by one bit in preparation for the PadLock prefixes.
Define most shift masks incrementally to reduce the redundant hard-coding. Introduce new shift for the VEX flags to replace the magic constant 32 in various places. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128822 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
6c8afd728e
commit
229e4523f2
@ -91,21 +91,21 @@ class REX_W { bit hasREX_WPrefix = 1; }
|
||||
class LOCK { bit hasLockPrefix = 1; }
|
||||
class SegFS { bits<2> SegOvrBits = 1; }
|
||||
class SegGS { bits<2> SegOvrBits = 2; }
|
||||
class TB { bits<4> Prefix = 1; }
|
||||
class REP { bits<4> Prefix = 2; }
|
||||
class D8 { bits<4> Prefix = 3; }
|
||||
class D9 { bits<4> Prefix = 4; }
|
||||
class DA { bits<4> Prefix = 5; }
|
||||
class DB { bits<4> Prefix = 6; }
|
||||
class DC { bits<4> Prefix = 7; }
|
||||
class DD { bits<4> Prefix = 8; }
|
||||
class DE { bits<4> Prefix = 9; }
|
||||
class DF { bits<4> Prefix = 10; }
|
||||
class XD { bits<4> Prefix = 11; }
|
||||
class XS { bits<4> Prefix = 12; }
|
||||
class T8 { bits<4> Prefix = 13; }
|
||||
class TA { bits<4> Prefix = 14; }
|
||||
class TF { bits<4> Prefix = 15; }
|
||||
class TB { bits<5> Prefix = 1; }
|
||||
class REP { bits<5> Prefix = 2; }
|
||||
class D8 { bits<5> Prefix = 3; }
|
||||
class D9 { bits<5> Prefix = 4; }
|
||||
class DA { bits<5> Prefix = 5; }
|
||||
class DB { bits<5> Prefix = 6; }
|
||||
class DC { bits<5> Prefix = 7; }
|
||||
class DD { bits<5> Prefix = 8; }
|
||||
class DE { bits<5> Prefix = 9; }
|
||||
class DF { bits<5> Prefix = 10; }
|
||||
class XD { bits<5> Prefix = 11; }
|
||||
class XS { bits<5> Prefix = 12; }
|
||||
class T8 { bits<5> Prefix = 13; }
|
||||
class TA { bits<5> Prefix = 14; }
|
||||
class TF { bits<5> Prefix = 15; }
|
||||
class VEX { bit hasVEXPrefix = 1; }
|
||||
class VEX_W { bit hasVEX_WPrefix = 1; }
|
||||
class VEX_4V : VEX { bit hasVEX_4VPrefix = 1; }
|
||||
@ -136,7 +136,7 @@ class X86Inst<bits<8> opcod, Format f, ImmType i, dag outs, dag ins,
|
||||
bit hasOpSizePrefix = 0; // Does this inst have a 0x66 prefix?
|
||||
bit hasAdSizePrefix = 0; // Does this inst have a 0x67 prefix?
|
||||
|
||||
bits<4> Prefix = 0; // Which prefix byte does this inst have?
|
||||
bits<5> Prefix = 0; // Which prefix byte does this inst have?
|
||||
bit hasREX_WPrefix = 0; // Does this inst require the REX.W prefix?
|
||||
FPFormat FPForm = NotFP; // What flavor of FP instruction is this?
|
||||
bit hasLockPrefix = 0; // Does this inst have a 0xF0 prefix?
|
||||
@ -154,20 +154,20 @@ class X86Inst<bits<8> opcod, Format f, ImmType i, dag outs, dag ins,
|
||||
let TSFlags{5-0} = FormBits;
|
||||
let TSFlags{6} = hasOpSizePrefix;
|
||||
let TSFlags{7} = hasAdSizePrefix;
|
||||
let TSFlags{11-8} = Prefix;
|
||||
let TSFlags{12} = hasREX_WPrefix;
|
||||
let TSFlags{15-13} = ImmT.Value;
|
||||
let TSFlags{18-16} = FPForm.Value;
|
||||
let TSFlags{19} = hasLockPrefix;
|
||||
let TSFlags{21-20} = SegOvrBits;
|
||||
let TSFlags{23-22} = ExeDomain.Value;
|
||||
let TSFlags{31-24} = Opcode;
|
||||
let TSFlags{32} = hasVEXPrefix;
|
||||
let TSFlags{33} = hasVEX_WPrefix;
|
||||
let TSFlags{34} = hasVEX_4VPrefix;
|
||||
let TSFlags{35} = hasVEX_i8ImmReg;
|
||||
let TSFlags{36} = hasVEX_L;
|
||||
let TSFlags{37} = has3DNow0F0FOpcode;
|
||||
let TSFlags{12-8} = Prefix;
|
||||
let TSFlags{13} = hasREX_WPrefix;
|
||||
let TSFlags{16-14} = ImmT.Value;
|
||||
let TSFlags{19-17} = FPForm.Value;
|
||||
let TSFlags{20} = hasLockPrefix;
|
||||
let TSFlags{22-21} = SegOvrBits;
|
||||
let TSFlags{24-23} = ExeDomain.Value;
|
||||
let TSFlags{32-25} = Opcode;
|
||||
let TSFlags{33} = hasVEXPrefix;
|
||||
let TSFlags{34} = hasVEX_WPrefix;
|
||||
let TSFlags{35} = hasVEX_4VPrefix;
|
||||
let TSFlags{36} = hasVEX_i8ImmReg;
|
||||
let TSFlags{37} = hasVEX_L;
|
||||
let TSFlags{38} = has3DNow0F0FOpcode;
|
||||
}
|
||||
|
||||
class PseudoI<dag oops, dag iops, list<dag> pattern>
|
||||
|
@ -347,7 +347,7 @@ namespace X86II {
|
||||
// set, there is no prefix byte for obtaining a multibyte opcode.
|
||||
//
|
||||
Op0Shift = 8,
|
||||
Op0Mask = 0xF << Op0Shift,
|
||||
Op0Mask = 0x1F << Op0Shift,
|
||||
|
||||
// TB - TwoByte - Set if this instruction has a two byte opcode, which
|
||||
// starts with a 0x0F byte before the real opcode.
|
||||
@ -380,13 +380,13 @@ namespace X86II {
|
||||
// etc. We only cares about REX.W and REX.R bits and only the former is
|
||||
// statically determined.
|
||||
//
|
||||
REXShift = 12,
|
||||
REXShift = Op0Shift + 5,
|
||||
REX_W = 1 << REXShift,
|
||||
|
||||
//===------------------------------------------------------------------===//
|
||||
// This three-bit field describes the size of an immediate operand. Zero is
|
||||
// unused so that we can tell if we forgot to set a value.
|
||||
ImmShift = 13,
|
||||
ImmShift = REXShift + 1,
|
||||
ImmMask = 7 << ImmShift,
|
||||
Imm8 = 1 << ImmShift,
|
||||
Imm8PCRel = 2 << ImmShift,
|
||||
@ -400,7 +400,7 @@ namespace X86II {
|
||||
// FP Instruction Classification... Zero is non-fp instruction.
|
||||
|
||||
// FPTypeMask - Mask for all of the FP types...
|
||||
FPTypeShift = 16,
|
||||
FPTypeShift = ImmShift + 3,
|
||||
FPTypeMask = 7 << FPTypeShift,
|
||||
|
||||
// NotFP - The default, set for instructions that do not use FP registers.
|
||||
@ -433,25 +433,26 @@ namespace X86II {
|
||||
SpecialFP = 7 << FPTypeShift,
|
||||
|
||||
// Lock prefix
|
||||
LOCKShift = 19,
|
||||
LOCKShift = FPTypeShift + 3,
|
||||
LOCK = 1 << LOCKShift,
|
||||
|
||||
// Segment override prefixes. Currently we just need ability to address
|
||||
// stuff in gs and fs segments.
|
||||
SegOvrShift = 20,
|
||||
SegOvrShift = LOCKShift + 1,
|
||||
SegOvrMask = 3 << SegOvrShift,
|
||||
FS = 1 << SegOvrShift,
|
||||
GS = 2 << SegOvrShift,
|
||||
|
||||
// Execution domain for SSE instructions in bits 22, 23.
|
||||
// 0 in bits 22-23 means normal, non-SSE instruction.
|
||||
SSEDomainShift = 22,
|
||||
// Execution domain for SSE instructions in bits 23, 24.
|
||||
// 0 in bits 23-24 means normal, non-SSE instruction.
|
||||
SSEDomainShift = SegOvrShift + 2,
|
||||
|
||||
OpcodeShift = 24,
|
||||
OpcodeShift = SSEDomainShift + 2,
|
||||
OpcodeMask = 0xFF << OpcodeShift,
|
||||
|
||||
//===------------------------------------------------------------------===//
|
||||
/// VEX - The opcode prefix used by AVX instructions
|
||||
VEXShift = OpcodeShift + 8,
|
||||
VEX = 1U << 0,
|
||||
|
||||
/// VEX_W - Has a opcode specific functionality, but is used in the same
|
||||
@ -549,7 +550,7 @@ namespace X86II {
|
||||
case X86II::MRMDestMem:
|
||||
return 0;
|
||||
case X86II::MRMSrcMem: {
|
||||
bool HasVEX_4V = (TSFlags >> 32) & X86II::VEX_4V;
|
||||
bool HasVEX_4V = (TSFlags >> X86II::VEXShift) & X86II::VEX_4V;
|
||||
unsigned FirstMemOp = 1;
|
||||
if (HasVEX_4V)
|
||||
++FirstMemOp;// Skip the register source (which is encoded in VEX_VVVV).
|
||||
|
@ -382,7 +382,7 @@ void X86MCCodeEmitter::EmitVEXOpcodePrefix(uint64_t TSFlags, unsigned &CurByte,
|
||||
const TargetInstrDesc &Desc,
|
||||
raw_ostream &OS) const {
|
||||
bool HasVEX_4V = false;
|
||||
if ((TSFlags >> 32) & X86II::VEX_4V)
|
||||
if ((TSFlags >> X86II::VEXShift) & X86II::VEX_4V)
|
||||
HasVEX_4V = true;
|
||||
|
||||
// VEX_R: opcode externsion equivalent to REX.R in
|
||||
@ -446,10 +446,10 @@ void X86MCCodeEmitter::EmitVEXOpcodePrefix(uint64_t TSFlags, unsigned &CurByte,
|
||||
if (TSFlags & X86II::OpSize)
|
||||
VEX_PP = 0x01;
|
||||
|
||||
if ((TSFlags >> 32) & X86II::VEX_W)
|
||||
if ((TSFlags >> X86II::VEXShift) & X86II::VEX_W)
|
||||
VEX_W = 1;
|
||||
|
||||
if ((TSFlags >> 32) & X86II::VEX_L)
|
||||
if ((TSFlags >> X86II::VEXShift) & X86II::VEX_L)
|
||||
VEX_L = 1;
|
||||
|
||||
switch (TSFlags & X86II::Op0Mask) {
|
||||
@ -518,7 +518,7 @@ void X86MCCodeEmitter::EmitVEXOpcodePrefix(uint64_t TSFlags, unsigned &CurByte,
|
||||
|
||||
// If the last register should be encoded in the immediate field
|
||||
// do not use any bit from VEX prefix to this register, ignore it
|
||||
if ((TSFlags >> 32) & X86II::VEX_I8IMM)
|
||||
if ((TSFlags >> X86II::VEXShift) & X86II::VEX_I8IMM)
|
||||
NumOps--;
|
||||
|
||||
for (; CurOp != NumOps; ++CurOp) {
|
||||
@ -819,9 +819,9 @@ EncodeInstruction(const MCInst &MI, raw_ostream &OS,
|
||||
// It uses the VEX.VVVV field?
|
||||
bool HasVEX_4V = false;
|
||||
|
||||
if ((TSFlags >> 32) & X86II::VEX)
|
||||
if ((TSFlags >> X86II::VEXShift) & X86II::VEX)
|
||||
HasVEXPrefix = true;
|
||||
if ((TSFlags >> 32) & X86II::VEX_4V)
|
||||
if ((TSFlags >> X86II::VEXShift) & X86II::VEX_4V)
|
||||
HasVEX_4V = true;
|
||||
|
||||
|
||||
@ -837,7 +837,7 @@ EncodeInstruction(const MCInst &MI, raw_ostream &OS,
|
||||
|
||||
unsigned char BaseOpcode = X86II::getBaseOpcodeFor(TSFlags);
|
||||
|
||||
if ((TSFlags >> 32) & X86II::Has3DNow0F0FOpcode)
|
||||
if ((TSFlags >> X86II::VEXShift) & X86II::Has3DNow0F0FOpcode)
|
||||
BaseOpcode = 0x0F; // Weird 3DNow! encoding.
|
||||
|
||||
unsigned SrcRegNum = 0;
|
||||
@ -994,7 +994,7 @@ EncodeInstruction(const MCInst &MI, raw_ostream &OS,
|
||||
if (CurOp != NumOps) {
|
||||
// The last source register of a 4 operand instruction in AVX is encoded
|
||||
// in bits[7:4] of a immediate byte, and bits[3:0] are ignored.
|
||||
if ((TSFlags >> 32) & X86II::VEX_I8IMM) {
|
||||
if ((TSFlags >> X86II::VEXShift) & X86II::VEX_I8IMM) {
|
||||
const MCOperand &MO = MI.getOperand(CurOp++);
|
||||
bool IsExtReg =
|
||||
X86InstrInfo::isX86_64ExtendedReg(MO.getReg());
|
||||
@ -1017,7 +1017,7 @@ EncodeInstruction(const MCInst &MI, raw_ostream &OS,
|
||||
}
|
||||
}
|
||||
|
||||
if ((TSFlags >> 32) & X86II::Has3DNow0F0FOpcode)
|
||||
if ((TSFlags >> X86II::VEXShift) & X86II::Has3DNow0F0FOpcode)
|
||||
EmitByte(X86II::getBaseOpcodeFor(TSFlags), CurByte, OS);
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user