Changeset View
Changeset View
Standalone View
Standalone View
lib/TableGen/Record.cpp
Show First 20 Lines • Show All 780 Lines • ▼ Show 20 Lines | Init *UnOpInit::resolveReferences(Resolver &R) const { | ||||
if (LHS != lhs || (R.isFinal() && getOpcode() == CAST)) | if (LHS != lhs || (R.isFinal() && getOpcode() == CAST)) | ||||
return (UnOpInit::get(getOpcode(), lhs, getType())) | return (UnOpInit::get(getOpcode(), lhs, getType())) | ||||
->Fold(R.getCurrentRecord(), R.isFinal()); | ->Fold(R.getCurrentRecord(), R.isFinal()); | ||||
return const_cast<UnOpInit *>(this); | return const_cast<UnOpInit *>(this); | ||||
} | } | ||||
std::string UnOpInit::getAsString() const { | std::string UnOpInit::getAsString() const { | ||||
std::string Result; | std::string OpSuffix; | ||||
switch (getOpcode()) { | switch (getOpcode()) { | ||||
case CAST: Result = "!cast<" + getType()->getAsString() + ">"; break; | case CAST: OpSuffix += "<" + getType()->getAsString() + ">"; break; | ||||
case HEAD: Result = "!head"; break; | default: break; | ||||
case TAIL: Result = "!tail"; break; | } | ||||
case SIZE: Result = "!size"; break; | return getOperatorName() + OpSuffix + "(" + LHS->getAsString() + ")"; | ||||
case EMPTY: Result = "!empty"; break; | } | ||||
std::string UnOpInit::getOperatorName() const { | |||||
switch (getOpcode()) { | |||||
case CAST: return "!cast"; | |||||
case HEAD: return "!head"; | |||||
case TAIL: return "!tail"; | |||||
case SIZE: return "!size"; | |||||
case EMPTY: return "!empty"; | |||||
default: llvm_unreachable("bad unop opcode"); | |||||
} | } | ||||
return Result + "(" + LHS->getAsString() + ")"; | |||||
} | } | ||||
static void | static void | ||||
ProfileBinOpInit(FoldingSetNodeID &ID, unsigned Opcode, Init *LHS, Init *RHS, | ProfileBinOpInit(FoldingSetNodeID &ID, unsigned Opcode, Init *LHS, Init *RHS, | ||||
RecTy *Type) { | RecTy *Type) { | ||||
ID.AddInteger(Opcode); | ID.AddInteger(Opcode); | ||||
ID.AddPointer(LHS); | ID.AddPointer(LHS); | ||||
ID.AddPointer(RHS); | ID.AddPointer(RHS); | ||||
▲ Show 20 Lines • Show All 158 Lines • ▼ Show 20 Lines | Init *BinOpInit::resolveReferences(Resolver &R) const { | ||||
if (LHS != lhs || RHS != rhs) | if (LHS != lhs || RHS != rhs) | ||||
return (BinOpInit::get(getOpcode(), lhs, rhs, getType())) | return (BinOpInit::get(getOpcode(), lhs, rhs, getType())) | ||||
->Fold(R.getCurrentRecord()); | ->Fold(R.getCurrentRecord()); | ||||
return const_cast<BinOpInit *>(this); | return const_cast<BinOpInit *>(this); | ||||
} | } | ||||
std::string BinOpInit::getAsString() const { | std::string BinOpInit::getAsString() const { | ||||
std::string Result; | return getOperatorName() + "(" + LHS->getAsString() + ", " + | ||||
RHS->getAsString() + ")"; | |||||
} | |||||
std::string BinOpInit::getOperatorName() const { | |||||
switch (getOpcode()) { | switch (getOpcode()) { | ||||
case CONCAT: Result = "!con"; break; | case CONCAT: return "!con"; | ||||
case ADD: Result = "!add"; break; | case ADD: return "!add"; | ||||
case AND: Result = "!and"; break; | case AND: return "!and"; | ||||
case OR: Result = "!or"; break; | case OR: return "!or"; | ||||
case SHL: Result = "!shl"; break; | case SHL: return "!shl"; | ||||
case SRA: Result = "!sra"; break; | case SRA: return "!sra"; | ||||
case SRL: Result = "!srl"; break; | case SRL: return "!srl"; | ||||
case EQ: Result = "!eq"; break; | case EQ: return "!eq"; | ||||
case NE: Result = "!ne"; break; | case NE: return "!ne"; | ||||
case LE: Result = "!le"; break; | case LE: return "!le"; | ||||
case LT: Result = "!lt"; break; | case LT: return "!lt"; | ||||
case GE: Result = "!ge"; break; | case GE: return "!ge"; | ||||
case GT: Result = "!gt"; break; | case GT: return "!gt"; | ||||
case LISTCONCAT: Result = "!listconcat"; break; | case LISTCONCAT: return "!listconcat"; | ||||
case STRCONCAT: Result = "!strconcat"; break; | case STRCONCAT: return "!strconcat"; | ||||
default: llvm_unreachable("bad binop opcode"); | |||||
} | } | ||||
return Result + "(" + LHS->getAsString() + ", " + RHS->getAsString() + ")"; | |||||
} | } | ||||
static void | static void | ||||
ProfileTernOpInit(FoldingSetNodeID &ID, unsigned Opcode, Init *LHS, Init *MHS, | ProfileTernOpInit(FoldingSetNodeID &ID, unsigned Opcode, Init *LHS, Init *MHS, | ||||
Init *RHS, RecTy *Type) { | Init *RHS, RecTy *Type) { | ||||
ID.AddInteger(Opcode); | ID.AddInteger(Opcode); | ||||
ID.AddPointer(LHS); | ID.AddPointer(LHS); | ||||
ID.AddPointer(MHS); | ID.AddPointer(MHS); | ||||
▲ Show 20 Lines • Show All 190 Lines • ▼ Show 20 Lines | Init *TernOpInit::resolveReferences(Resolver &R) const { | ||||
if (LHS != lhs || MHS != mhs || RHS != rhs) | if (LHS != lhs || MHS != mhs || RHS != rhs) | ||||
return (TernOpInit::get(getOpcode(), lhs, mhs, rhs, getType())) | return (TernOpInit::get(getOpcode(), lhs, mhs, rhs, getType())) | ||||
->Fold(R.getCurrentRecord()); | ->Fold(R.getCurrentRecord()); | ||||
return const_cast<TernOpInit *>(this); | return const_cast<TernOpInit *>(this); | ||||
} | } | ||||
std::string TernOpInit::getAsString() const { | std::string TernOpInit::getAsString() const { | ||||
std::string Result; | return getOperatorName() + "(" + LHS->getAsString() + ", " + | ||||
MHS->getAsString() + ", " + RHS->getAsString() + ")"; | |||||
} | |||||
std::string TernOpInit::getOperatorName() const { | |||||
switch (getOpcode()) { | switch (getOpcode()) { | ||||
case SUBST: Result = "!subst"; break; | case SUBST: return "!subst"; | ||||
case FOREACH: Result = "!foreach"; break; | case FOREACH: return "!foreach"; | ||||
case IF: Result = "!if"; break; | case IF: return "!if"; | ||||
case DAG: Result = "!dag"; break; | case DAG: return "!dag"; | ||||
default: llvm_unreachable("bad ternop opcode"); | |||||
} | } | ||||
return Result + "(" + LHS->getAsString() + ", " + MHS->getAsString() + ", " + | |||||
RHS->getAsString() + ")"; | |||||
} | } | ||||
static void ProfileFoldOpInit(FoldingSetNodeID &ID, Init *A, Init *B, | static void ProfileFoldOpInit(FoldingSetNodeID &ID, Init *A, Init *B, | ||||
Init *Start, Init *List, Init *Expr, | Init *Start, Init *List, Init *Expr, | ||||
RecTy *Type) { | RecTy *Type) { | ||||
ID.AddPointer(Start); | ID.AddPointer(Start); | ||||
ID.AddPointer(List); | ID.AddPointer(List); | ||||
ID.AddPointer(A); | ID.AddPointer(A); | ||||
▲ Show 20 Lines • Show All 1,046 Lines • Show Last 20 Lines |