mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-23 02:29:18 +00:00
Teach TableGen to understand X.Y notation in the TSFlagsFields strings.
Remove much horribleness from X86InstrFormats as a result. Similar simplifications are probably possible for other targets. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99539 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7bf198fd60
commit
70feca409e
@ -160,11 +160,11 @@ def X86InstrInfo : InstrInfo {
|
|||||||
"hasAdSizePrefix",
|
"hasAdSizePrefix",
|
||||||
"Prefix",
|
"Prefix",
|
||||||
"hasREX_WPrefix",
|
"hasREX_WPrefix",
|
||||||
"ImmTypeBits",
|
"ImmT.Value",
|
||||||
"FPFormBits",
|
"FPForm.Value",
|
||||||
"hasLockPrefix",
|
"hasLockPrefix",
|
||||||
"SegOvrBits",
|
"SegOvrBits",
|
||||||
"DomainBits",
|
"ExeDomain.Value",
|
||||||
"Opcode"];
|
"Opcode"];
|
||||||
let TSFlagsShifts = [0,
|
let TSFlagsShifts = [0,
|
||||||
6,
|
6,
|
||||||
|
@ -111,7 +111,6 @@ class X86Inst<bits<8> opcod, Format f, ImmType i, dag outs, dag ins,
|
|||||||
Format Form = f;
|
Format Form = f;
|
||||||
bits<6> FormBits = Form.Value;
|
bits<6> FormBits = Form.Value;
|
||||||
ImmType ImmT = i;
|
ImmType ImmT = i;
|
||||||
bits<3> ImmTypeBits = ImmT.Value;
|
|
||||||
|
|
||||||
dag OutOperandList = outs;
|
dag OutOperandList = outs;
|
||||||
dag InOperandList = ins;
|
dag InOperandList = ins;
|
||||||
@ -125,12 +124,10 @@ class X86Inst<bits<8> opcod, Format f, ImmType i, dag outs, dag ins,
|
|||||||
|
|
||||||
bits<4> Prefix = 0; // Which prefix byte does this inst have?
|
bits<4> Prefix = 0; // Which prefix byte does this inst have?
|
||||||
bit hasREX_WPrefix = 0; // Does this inst requires the REX.W prefix?
|
bit hasREX_WPrefix = 0; // Does this inst requires the REX.W prefix?
|
||||||
FPFormat FPForm; // What flavor of FP instruction is this?
|
FPFormat FPForm = NotFP; // What flavor of FP instruction is this?
|
||||||
bits<3> FPFormBits = 0;
|
|
||||||
bit hasLockPrefix = 0; // Does this inst have a 0xF0 prefix?
|
bit hasLockPrefix = 0; // Does this inst have a 0xF0 prefix?
|
||||||
bits<2> SegOvrBits = 0; // Segment override prefix.
|
bits<2> SegOvrBits = 0; // Segment override prefix.
|
||||||
Domain Dom = d;
|
Domain ExeDomain = d;
|
||||||
bits<2> DomainBits = Dom.Value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class I<bits<8> o, Format f, dag outs, dag ins, string asm,
|
class I<bits<8> o, Format f, dag outs, dag ins, string asm,
|
||||||
@ -179,7 +176,7 @@ class FPI<bits<8> o, Format F, dag outs, dag ins, string asm>
|
|||||||
// FpI_ - Floating Point Psuedo Instruction template. Not Predicated.
|
// FpI_ - Floating Point Psuedo Instruction template. Not Predicated.
|
||||||
class FpI_<dag outs, dag ins, FPFormat fp, list<dag> pattern>
|
class FpI_<dag outs, dag ins, FPFormat fp, list<dag> pattern>
|
||||||
: X86Inst<0, Pseudo, NoImm, outs, ins, ""> {
|
: X86Inst<0, Pseudo, NoImm, outs, ins, ""> {
|
||||||
let FPForm = fp; let FPFormBits = FPForm.Value;
|
let FPForm = fp;
|
||||||
let Pattern = pattern;
|
let Pattern = pattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -587,7 +587,7 @@ let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
|
|||||||
|
|
||||||
// Return instructions.
|
// Return instructions.
|
||||||
let isTerminator = 1, isReturn = 1, isBarrier = 1,
|
let isTerminator = 1, isReturn = 1, isBarrier = 1,
|
||||||
hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
|
hasCtrlDep = 1, FPForm = SpecialFP in {
|
||||||
def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
|
def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
|
||||||
"ret",
|
"ret",
|
||||||
[(X86retflag 0)]>;
|
[(X86retflag 0)]>;
|
||||||
|
@ -337,7 +337,7 @@ void InstrInfoEmitter::emitShiftedValue(Record *R, StringInit *Val,
|
|||||||
IntInit *ShiftInt, raw_ostream &OS) {
|
IntInit *ShiftInt, raw_ostream &OS) {
|
||||||
if (Val == 0 || ShiftInt == 0)
|
if (Val == 0 || ShiftInt == 0)
|
||||||
throw std::string("Illegal value or shift amount in TargetInfo*!");
|
throw std::string("Illegal value or shift amount in TargetInfo*!");
|
||||||
RecordVal *RV = R->getValue(Val->getValue());
|
RecordVal *RV = R->getDottedValue(Val->getValue());
|
||||||
int Shift = ShiftInt->getValue();
|
int Shift = ShiftInt->getValue();
|
||||||
|
|
||||||
if (RV == 0 || RV->getValue() == 0) {
|
if (RV == 0 || RV->getValue() == 0) {
|
||||||
|
@ -1307,6 +1307,16 @@ void Record::resolveReferencesTo(const RecordVal *RV) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RecordVal *Record::getDottedValue(StringRef Name) {
|
||||||
|
size_t pos = Name.find('.');
|
||||||
|
if (pos == StringRef::npos)
|
||||||
|
return getValue(Name);
|
||||||
|
RecordVal *RV = getValue(Name.substr(0, pos));
|
||||||
|
if (!RV) return 0;
|
||||||
|
DefInit *DI = dynamic_cast<DefInit*>(RV->getValue());
|
||||||
|
if (!DI) return 0;
|
||||||
|
return DI->getDef()->getDottedValue(Name.substr(pos+1));
|
||||||
|
}
|
||||||
|
|
||||||
void Record::dump() const { errs() << *this; }
|
void Record::dump() const { errs() << *this; }
|
||||||
|
|
||||||
|
@ -1262,6 +1262,9 @@ public:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Like getValue, but allow dotting into members: X.Y
|
||||||
|
RecordVal *getDottedValue(StringRef Name);
|
||||||
|
|
||||||
void addTemplateArg(StringRef Name) {
|
void addTemplateArg(StringRef Name) {
|
||||||
assert(!isTemplateArg(Name) && "Template arg already defined!");
|
assert(!isTemplateArg(Name) && "Template arg already defined!");
|
||||||
TemplateArgs.push_back(Name);
|
TemplateArgs.push_back(Name);
|
||||||
|
Loading…
Reference in New Issue
Block a user