mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-22 03:39:03 +00:00
Add target independent MachineInstr's to represent subreg insert/extract in MBB's. PR1350
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40518 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
518143d795
commit
08d52071ba
@ -177,7 +177,9 @@ public:
|
|||||||
enum {
|
enum {
|
||||||
PHI = 0,
|
PHI = 0,
|
||||||
INLINEASM = 1,
|
INLINEASM = 1,
|
||||||
LABEL = 2
|
LABEL = 2,
|
||||||
|
EXTRACT_SUBREG = 3,
|
||||||
|
INSERT_SUBREG = 4
|
||||||
};
|
};
|
||||||
|
|
||||||
unsigned getNumOpcodes() const { return NumOpcodes; }
|
unsigned getNumOpcodes() const { return NumOpcodes; }
|
||||||
|
@ -321,6 +321,18 @@ def LABEL : Instruction {
|
|||||||
let Namespace = "TargetInstrInfo";
|
let Namespace = "TargetInstrInfo";
|
||||||
let hasCtrlDep = 1;
|
let hasCtrlDep = 1;
|
||||||
}
|
}
|
||||||
|
def EXTRACT_SUBREG : Instruction {
|
||||||
|
let OutOperandList = (ops variable_ops);
|
||||||
|
let InOperandList = (ops variable_ops);
|
||||||
|
let AsmString = "";
|
||||||
|
let Namespace = "TargetInstrInfo";
|
||||||
|
}
|
||||||
|
def INSERT_SUBREG : Instruction {
|
||||||
|
let OutOperandList = (ops variable_ops);
|
||||||
|
let InOperandList = (ops variable_ops);
|
||||||
|
let AsmString = "";
|
||||||
|
let Namespace = "TargetInstrInfo";
|
||||||
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// AsmWriter - This class can be implemented by targets that need to customize
|
// AsmWriter - This class can be implemented by targets that need to customize
|
||||||
|
@ -26,7 +26,9 @@ void CodeEmitterGen::reverseBits(std::vector<Record*> &Insts) {
|
|||||||
Record *R = *I;
|
Record *R = *I;
|
||||||
if (R->getName() == "PHI" ||
|
if (R->getName() == "PHI" ||
|
||||||
R->getName() == "INLINEASM" ||
|
R->getName() == "INLINEASM" ||
|
||||||
R->getName() == "LABEL") continue;
|
R->getName() == "LABEL" ||
|
||||||
|
R->getName() == "EXTRACT_SUBREG" ||
|
||||||
|
R->getName() == "INSERT_SUBREG") continue;
|
||||||
|
|
||||||
BitsInit *BI = R->getValueAsBitsInit("Inst");
|
BitsInit *BI = R->getValueAsBitsInit("Inst");
|
||||||
|
|
||||||
@ -97,7 +99,9 @@ void CodeEmitterGen::run(std::ostream &o) {
|
|||||||
|
|
||||||
if (R->getName() == "PHI" ||
|
if (R->getName() == "PHI" ||
|
||||||
R->getName() == "INLINEASM" ||
|
R->getName() == "INLINEASM" ||
|
||||||
R->getName() == "LABEL") {
|
R->getName() == "LABEL" ||
|
||||||
|
R->getName() == "EXTRACT_SUBREG" ||
|
||||||
|
R->getName() == "INSERT_SUBREG") {
|
||||||
o << " 0U";
|
o << " 0U";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -127,7 +131,9 @@ void CodeEmitterGen::run(std::ostream &o) {
|
|||||||
|
|
||||||
if (InstName == "PHI" ||
|
if (InstName == "PHI" ||
|
||||||
InstName == "INLINEASM" ||
|
InstName == "INLINEASM" ||
|
||||||
InstName == "LABEL") continue;
|
InstName == "LABEL"||
|
||||||
|
InstName == "EXTRACT_SUBREG" ||
|
||||||
|
InstName == "INSERT_SUBREG") continue;
|
||||||
|
|
||||||
BitsInit *BI = R->getValueAsBitsInit("Inst");
|
BitsInit *BI = R->getValueAsBitsInit("Inst");
|
||||||
const std::vector<RecordVal> &Vals = R->getValues();
|
const std::vector<RecordVal> &Vals = R->getValues();
|
||||||
|
@ -275,14 +275,28 @@ getInstructionsByEnumValue(std::vector<const CodeGenInstruction*>
|
|||||||
if (I == Instructions.end()) throw "Could not find 'LABEL' instruction!";
|
if (I == Instructions.end()) throw "Could not find 'LABEL' instruction!";
|
||||||
const CodeGenInstruction *LABEL = &I->second;
|
const CodeGenInstruction *LABEL = &I->second;
|
||||||
|
|
||||||
|
I = getInstructions().find("EXTRACT_SUBREG");
|
||||||
|
if (I == Instructions.end())
|
||||||
|
throw "Could not find 'EXTRACT_SUBREG' instruction!";
|
||||||
|
const CodeGenInstruction *EXTRACT_SUBREG = &I->second;
|
||||||
|
|
||||||
|
I = getInstructions().find("INSERT_SUBREG");
|
||||||
|
if (I == Instructions.end())
|
||||||
|
throw "Could not find 'INSERT_SUBREG' instruction!";
|
||||||
|
const CodeGenInstruction *INSERT_SUBREG = &I->second;
|
||||||
|
|
||||||
// Print out the rest of the instructions now.
|
// Print out the rest of the instructions now.
|
||||||
NumberedInstructions.push_back(PHI);
|
NumberedInstructions.push_back(PHI);
|
||||||
NumberedInstructions.push_back(INLINEASM);
|
NumberedInstructions.push_back(INLINEASM);
|
||||||
NumberedInstructions.push_back(LABEL);
|
NumberedInstructions.push_back(LABEL);
|
||||||
|
NumberedInstructions.push_back(EXTRACT_SUBREG);
|
||||||
|
NumberedInstructions.push_back(INSERT_SUBREG);
|
||||||
for (inst_iterator II = inst_begin(), E = inst_end(); II != E; ++II)
|
for (inst_iterator II = inst_begin(), E = inst_end(); II != E; ++II)
|
||||||
if (&II->second != PHI &&
|
if (&II->second != PHI &&
|
||||||
&II->second != INLINEASM &&
|
&II->second != INLINEASM &&
|
||||||
&II->second != LABEL)
|
&II->second != LABEL &&
|
||||||
|
&II->second != EXTRACT_SUBREG &&
|
||||||
|
&II->second != INSERT_SUBREG)
|
||||||
NumberedInstructions.push_back(&II->second);
|
NumberedInstructions.push_back(&II->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3729,6 +3729,33 @@ void DAGISelEmitter::EmitInstructionSelector(std::ostream &OS) {
|
|||||||
<< " MVT::Other, Tmp, Chain);\n"
|
<< " MVT::Other, Tmp, Chain);\n"
|
||||||
<< "}\n\n";
|
<< "}\n\n";
|
||||||
|
|
||||||
|
OS << "SDNode *Select_EXTRACT_SUBREG(const SDOperand &N) {\n"
|
||||||
|
<< " SDOperand N0 = N.getOperand(0);\n"
|
||||||
|
<< " SDOperand N1 = N.getOperand(1);\n"
|
||||||
|
<< " unsigned C = cast<ConstantSDNode>(N1)->getValue();\n"
|
||||||
|
<< " SDOperand Tmp = CurDAG->getTargetConstant(C, MVT::i32);\n"
|
||||||
|
<< " AddToISelQueue(N0);\n"
|
||||||
|
<< " return CurDAG->getTargetNode(TargetInstrInfo::EXTRACT_SUBREG,\n"
|
||||||
|
<< " N.getValueType(), N0, Tmp);\n"
|
||||||
|
<< "}\n\n";
|
||||||
|
|
||||||
|
OS << "SDNode *Select_INSERT_SUBREG(const SDOperand &N) {\n"
|
||||||
|
<< " SDOperand N0 = N.getOperand(0);\n"
|
||||||
|
<< " SDOperand N1 = N.getOperand(1);\n"
|
||||||
|
<< " SDOperand N2 = N.getOperand(2);\n"
|
||||||
|
<< " unsigned C = cast<ConstantSDNode>(N2)->getValue();\n"
|
||||||
|
<< " SDOperand Tmp = CurDAG->getTargetConstant(C, MVT::i32);\n"
|
||||||
|
<< " AddToISelQueue(N1);\n"
|
||||||
|
<< " if (N0.getOpcode() == ISD::UNDEF) {\n"
|
||||||
|
<< " return CurDAG->getTargetNode(TargetInstrInfo::EXTRACT_SUBREG,\n"
|
||||||
|
<< " N.getValueType(), N1, Tmp);\n"
|
||||||
|
<< " } else {\n"
|
||||||
|
<< " AddToISelQueue(N0);\n"
|
||||||
|
<< " return CurDAG->getTargetNode(TargetInstrInfo::EXTRACT_SUBREG,\n"
|
||||||
|
<< " N.getValueType(), N0, N1, Tmp);\n"
|
||||||
|
<< " }\n"
|
||||||
|
<< "}\n\n";
|
||||||
|
|
||||||
OS << "// The main instruction selector code.\n"
|
OS << "// The main instruction selector code.\n"
|
||||||
<< "SDNode *SelectCode(SDOperand N) {\n"
|
<< "SDNode *SelectCode(SDOperand N) {\n"
|
||||||
<< " if (N.getOpcode() >= ISD::BUILTIN_OP_END &&\n"
|
<< " if (N.getOpcode() >= ISD::BUILTIN_OP_END &&\n"
|
||||||
@ -3766,7 +3793,9 @@ void DAGISelEmitter::EmitInstructionSelector(std::ostream &OS) {
|
|||||||
<< " return NULL;\n"
|
<< " return NULL;\n"
|
||||||
<< " }\n"
|
<< " }\n"
|
||||||
<< " case ISD::INLINEASM: return Select_INLINEASM(N);\n"
|
<< " case ISD::INLINEASM: return Select_INLINEASM(N);\n"
|
||||||
<< " case ISD::LABEL: return Select_LABEL(N);\n";
|
<< " case ISD::LABEL: return Select_LABEL(N);\n"
|
||||||
|
<< " case ISD::EXTRACT_SUBREG: return Select_EXTRACT_SUBREG(N);\n"
|
||||||
|
<< " case ISD::INSERT_SUBREG: return Select_INSERT_SUBREG(N);\n";
|
||||||
|
|
||||||
|
|
||||||
// Loop over all of the case statements, emiting a call to each method we
|
// Loop over all of the case statements, emiting a call to each method we
|
||||||
|
@ -325,7 +325,9 @@ void InstrInfoEmitter::emitShiftedValue(Record *R, StringInit *Val,
|
|||||||
// This isn't an error if this is a builtin instruction.
|
// This isn't an error if this is a builtin instruction.
|
||||||
if (R->getName() != "PHI" &&
|
if (R->getName() != "PHI" &&
|
||||||
R->getName() != "INLINEASM" &&
|
R->getName() != "INLINEASM" &&
|
||||||
R->getName() != "LABEL")
|
R->getName() != "LABEL" &&
|
||||||
|
R->getName() != "EXTRACT_SUBREG" &&
|
||||||
|
R->getName() != "INSERT_SUBREG")
|
||||||
throw R->getName() + " doesn't have a field named '" +
|
throw R->getName() + " doesn't have a field named '" +
|
||||||
Val->getValue() + "'!";
|
Val->getValue() + "'!";
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user