mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-28 04:33:05 +00:00
enhance tblgen to support anonymous defm's, use this to
simplify the X86 CMOVmr's. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115702 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
286997c745
commit
df72eaef3d
@ -860,22 +860,22 @@ multiclass CMOVmr<PatLeaf InvertedCond, Instruction Inst16, Instruction Inst32,
|
|||||||
(Inst64 GR64:$src2, addr:$src1)>;
|
(Inst64 GR64:$src2, addr:$src1)>;
|
||||||
}
|
}
|
||||||
|
|
||||||
defm CMOVAEmr : CMOVmr<X86_COND_B , CMOVAE16rm, CMOVAE32rm, CMOVAE64rm>;
|
defm : CMOVmr<X86_COND_B , CMOVAE16rm, CMOVAE32rm, CMOVAE64rm>;
|
||||||
defm CMOVBmr : CMOVmr<X86_COND_AE, CMOVB16rm , CMOVB32rm , CMOVB64rm>;
|
defm : CMOVmr<X86_COND_AE, CMOVB16rm , CMOVB32rm , CMOVB64rm>;
|
||||||
defm CMOVNEmr : CMOVmr<X86_COND_E , CMOVNE16rm, CMOVNE32rm, CMOVNE64rm>;
|
defm : CMOVmr<X86_COND_E , CMOVNE16rm, CMOVNE32rm, CMOVNE64rm>;
|
||||||
defm CMOVEmr : CMOVmr<X86_COND_NE, CMOVE16rm , CMOVE32rm , CMOVE64rm>;
|
defm : CMOVmr<X86_COND_NE, CMOVE16rm , CMOVE32rm , CMOVE64rm>;
|
||||||
defm CMOVAmr : CMOVmr<X86_COND_BE, CMOVA16rm , CMOVA32rm , CMOVA64rm>;
|
defm : CMOVmr<X86_COND_BE, CMOVA16rm , CMOVA32rm , CMOVA64rm>;
|
||||||
defm CMOVBEmr : CMOVmr<X86_COND_A , CMOVBErm16, CMOVBErm32, CMOVBErm64>;
|
defm : CMOVmr<X86_COND_A , CMOVBErm16, CMOVBErm32, CMOVBErm64>;
|
||||||
defm CMOVGEmr : CMOVmr<X86_COND_L , CMOVGE16rm, CMOVGE32rm, CMOVGE64rm>;
|
defm : CMOVmr<X86_COND_L , CMOVGE16rm, CMOVGE32rm, CMOVGE64rm>;
|
||||||
defm CMOVLmr : CMOVmr<X86_COND_GE, CMOVL16rm , CMOVL32rm , CMOVL64rm>;
|
defm : CMOVmr<X86_COND_GE, CMOVL16rm , CMOVL32rm , CMOVL64rm>;
|
||||||
defm CMOVGmr : CMOVmr<X86_COND_LE, CMOVG16rm , CMOVG32rm , CMOVG64rm>;
|
defm : CMOVmr<X86_COND_LE, CMOVG16rm , CMOVG32rm , CMOVG64rm>;
|
||||||
defm CMOVLEmr : CMOVmr<X86_COND_G , CMOVLE16rm, CMOVLE32rm, CMOVLE64rm>;
|
defm : CMOVmr<X86_COND_G , CMOVLE16rm, CMOVLE32rm, CMOVLE64rm>;
|
||||||
defm CMOVNPmr : CMOVmr<X86_COND_P , CMOVNP16rm, CMOVNP32rm, CMOVNP64rm>;
|
defm : CMOVmr<X86_COND_P , CMOVNP16rm, CMOVNP32rm, CMOVNP64rm>;
|
||||||
defm CMOVPmr : CMOVmr<X86_COND_NP, CMOVP16rm , CMOVP32rm , CMOVP64rm>;
|
defm : CMOVmr<X86_COND_NP, CMOVP16rm , CMOVP32rm , CMOVP64rm>;
|
||||||
defm CMOVNSmr : CMOVmr<X86_COND_S , CMOVNS16rm, CMOVNS32rm, CMOVNS64rm>;
|
defm : CMOVmr<X86_COND_S , CMOVNS16rm, CMOVNS32rm, CMOVNS64rm>;
|
||||||
defm CMOVSmr : CMOVmr<X86_COND_NS, CMOVS16rm , CMOVS32rm , CMOVS64rm>;
|
defm : CMOVmr<X86_COND_NS, CMOVS16rm , CMOVS32rm , CMOVS64rm>;
|
||||||
defm CMOVNOmr : CMOVmr<X86_COND_O , CMOVNO16rm, CMOVNO32rm, CMOVNO64rm>;
|
defm : CMOVmr<X86_COND_O , CMOVNO16rm, CMOVNO32rm, CMOVNO64rm>;
|
||||||
defm CMOVOmr : CMOVmr<X86_COND_NO, CMOVO16rm , CMOVO32rm , CMOVO64rm>;
|
defm : CMOVmr<X86_COND_NO, CMOVO16rm , CMOVO32rm , CMOVO64rm>;
|
||||||
|
|
||||||
// zextload bool -> zextload byte
|
// zextload bool -> zextload byte
|
||||||
def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
|
def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
|
||||||
|
@ -36,3 +36,15 @@ multiclass Y {
|
|||||||
|
|
||||||
// CHECK: int check = 0;
|
// CHECK: int check = 0;
|
||||||
defm Instr : Y, VEX;
|
defm Instr : Y, VEX;
|
||||||
|
|
||||||
|
|
||||||
|
// Anonymous defm.
|
||||||
|
|
||||||
|
multiclass SomeAnonymous<int x> {
|
||||||
|
def rm;
|
||||||
|
def mr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// These multiclasses shouldn't conflict.
|
||||||
|
defm : SomeAnonymous<1>;
|
||||||
|
defm : SomeAnonymous<2>;
|
@ -294,22 +294,25 @@ static bool isObjectStart(tgtok::TokKind K) {
|
|||||||
K == tgtok::Defm || K == tgtok::Let || K == tgtok::MultiClass;
|
K == tgtok::Defm || K == tgtok::Let || K == tgtok::MultiClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::string GetNewAnonymousName() {
|
||||||
|
static unsigned AnonCounter = 0;
|
||||||
|
return "anonymous."+utostr(AnonCounter++);
|
||||||
|
}
|
||||||
|
|
||||||
/// ParseObjectName - If an object name is specified, return it. Otherwise,
|
/// ParseObjectName - If an object name is specified, return it. Otherwise,
|
||||||
/// return an anonymous name.
|
/// return an anonymous name.
|
||||||
/// ObjectName ::= ID
|
/// ObjectName ::= ID
|
||||||
/// ObjectName ::= /*empty*/
|
/// ObjectName ::= /*empty*/
|
||||||
///
|
///
|
||||||
std::string TGParser::ParseObjectName() {
|
std::string TGParser::ParseObjectName() {
|
||||||
if (Lex.getCode() == tgtok::Id) {
|
if (Lex.getCode() != tgtok::Id)
|
||||||
|
return GetNewAnonymousName();
|
||||||
|
|
||||||
std::string Ret = Lex.getCurStrVal();
|
std::string Ret = Lex.getCurStrVal();
|
||||||
Lex.Lex();
|
Lex.Lex();
|
||||||
return Ret;
|
return Ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned AnonCounter = 0;
|
|
||||||
return "anonymous."+utostr(AnonCounter++);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// ParseClassID - Parse and resolve a reference to a class name. This returns
|
/// ParseClassID - Parse and resolve a reference to a class name. This returns
|
||||||
/// null on error.
|
/// null on error.
|
||||||
@ -1899,12 +1902,15 @@ bool TGParser::ParseMultiClass() {
|
|||||||
///
|
///
|
||||||
bool TGParser::ParseDefm(MultiClass *CurMultiClass) {
|
bool TGParser::ParseDefm(MultiClass *CurMultiClass) {
|
||||||
assert(Lex.getCode() == tgtok::Defm && "Unexpected token!");
|
assert(Lex.getCode() == tgtok::Defm && "Unexpected token!");
|
||||||
if (Lex.Lex() != tgtok::Id) // eat the defm.
|
|
||||||
return TokError("expected identifier after defm");
|
std::string DefmPrefix;
|
||||||
|
if (Lex.Lex() == tgtok::Id) { // eat the defm.
|
||||||
|
DefmPrefix = Lex.getCurStrVal();
|
||||||
|
Lex.Lex(); // Eat the defm prefix.
|
||||||
|
}
|
||||||
|
|
||||||
SMLoc DefmPrefixLoc = Lex.getLoc();
|
SMLoc DefmPrefixLoc = Lex.getLoc();
|
||||||
std::string DefmPrefix = Lex.getCurStrVal();
|
if (Lex.getCode() != tgtok::colon)
|
||||||
if (Lex.Lex() != tgtok::colon)
|
|
||||||
return TokError("expected ':' after defm identifier");
|
return TokError("expected ':' after defm identifier");
|
||||||
|
|
||||||
// Keep track of the new generated record definitions.
|
// Keep track of the new generated record definitions.
|
||||||
@ -1939,8 +1945,14 @@ bool TGParser::ParseDefm(MultiClass *CurMultiClass) {
|
|||||||
for (unsigned i = 0, e = MC->DefPrototypes.size(); i != e; ++i) {
|
for (unsigned i = 0, e = MC->DefPrototypes.size(); i != e; ++i) {
|
||||||
Record *DefProto = MC->DefPrototypes[i];
|
Record *DefProto = MC->DefPrototypes[i];
|
||||||
|
|
||||||
// Add in the defm name
|
// Add in the defm name. If the defm prefix is empty, give each
|
||||||
|
// instantiated def a unique name. Otherwise, if "#NAME#" exists in the
|
||||||
|
// name, substitute the prefix for #NAME#. Otherwise, use the defm name
|
||||||
|
// as a prefix.
|
||||||
std::string DefName = DefProto->getName();
|
std::string DefName = DefProto->getName();
|
||||||
|
if (DefmPrefix.empty()) {
|
||||||
|
DefName = GetNewAnonymousName();
|
||||||
|
} else {
|
||||||
std::string::size_type idx = DefName.find("#NAME#");
|
std::string::size_type idx = DefName.find("#NAME#");
|
||||||
if (idx != std::string::npos) {
|
if (idx != std::string::npos) {
|
||||||
DefName.replace(idx, 6, DefmPrefix);
|
DefName.replace(idx, 6, DefmPrefix);
|
||||||
@ -1948,6 +1960,7 @@ bool TGParser::ParseDefm(MultiClass *CurMultiClass) {
|
|||||||
// Add the suffix to the defm name to get the new name.
|
// Add the suffix to the defm name to get the new name.
|
||||||
DefName = DefmPrefix + DefName;
|
DefName = DefmPrefix + DefName;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Record *CurRec = new Record(DefName, DefmPrefixLoc);
|
Record *CurRec = new Record(DefName, DefmPrefixLoc);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user