mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-18 14:31:27 +00:00
Minor refactoring, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19753 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
741c118230
commit
5765dba5ce
@ -53,8 +53,9 @@ namespace {
|
|||||||
|
|
||||||
struct AsmWriterInst {
|
struct AsmWriterInst {
|
||||||
std::vector<AsmWriterOperand> Operands;
|
std::vector<AsmWriterOperand> Operands;
|
||||||
|
const CodeGenInstruction *CGI;
|
||||||
|
|
||||||
void ParseAsmString(const CodeGenInstruction &CGI, unsigned Variant);
|
AsmWriterInst(const CodeGenInstruction &CGI, unsigned Variant);
|
||||||
void EmitCode(std::ostream &OS) const {
|
void EmitCode(std::ostream &OS) const {
|
||||||
for (unsigned i = 0, e = Operands.size(); i != e; ++i)
|
for (unsigned i = 0, e = Operands.size(); i != e; ++i)
|
||||||
Operands[i].EmitCode(OS);
|
Operands[i].EmitCode(OS);
|
||||||
@ -84,8 +85,8 @@ void AsmWriterOperand::EmitCode(std::ostream &OS) const {
|
|||||||
/// ParseAsmString - Parse the specified Instruction's AsmString into this
|
/// ParseAsmString - Parse the specified Instruction's AsmString into this
|
||||||
/// AsmWriterInst.
|
/// AsmWriterInst.
|
||||||
///
|
///
|
||||||
void AsmWriterInst::ParseAsmString(const CodeGenInstruction &CGI,
|
AsmWriterInst::AsmWriterInst(const CodeGenInstruction &CGI, unsigned Variant) {
|
||||||
unsigned Variant) {
|
this->CGI = &CGI;
|
||||||
bool inVariant = false; // True if we are inside a {.|.|.} region.
|
bool inVariant = false; // True if we are inside a {.|.|.} region.
|
||||||
|
|
||||||
const std::string &AsmString = CGI.AsmString;
|
const std::string &AsmString = CGI.AsmString;
|
||||||
@ -152,10 +153,11 @@ void AsmWriterInst::ParseAsmString(const CodeGenInstruction &CGI,
|
|||||||
throw "Stray '$' in '" + CGI.Name + "' asm string, maybe you want $$?";
|
throw "Stray '$' in '" + CGI.Name + "' asm string, maybe you want $$?";
|
||||||
|
|
||||||
unsigned OpNo = CGI.getOperandNamed(VarName);
|
unsigned OpNo = CGI.getOperandNamed(VarName);
|
||||||
|
CodeGenInstruction::OperandInfo OpInfo = CGI.OperandList[OpNo];
|
||||||
|
|
||||||
// If this is a two-address instruction and we are not accessing the
|
// If this is a two-address instruction and we are not accessing the
|
||||||
// 0th operand, remove an operand.
|
// 0th operand, remove an operand.
|
||||||
unsigned MIOp = CGI.OperandList[OpNo].MIOperandNo;
|
unsigned MIOp = OpInfo.MIOperandNo;
|
||||||
if (CGI.isTwoAddress && MIOp != 0) {
|
if (CGI.isTwoAddress && MIOp != 0) {
|
||||||
if (MIOp == 1)
|
if (MIOp == 1)
|
||||||
throw "Should refer to operand #0 instead of #1 for two-address"
|
throw "Should refer to operand #0 instead of #1 for two-address"
|
||||||
@ -163,8 +165,8 @@ void AsmWriterInst::ParseAsmString(const CodeGenInstruction &CGI,
|
|||||||
--MIOp;
|
--MIOp;
|
||||||
}
|
}
|
||||||
|
|
||||||
Operands.push_back(AsmWriterOperand(CGI.OperandList[OpNo].PrinterMethodName,
|
Operands.push_back(AsmWriterOperand(OpInfo.PrinterMethodName,
|
||||||
MIOp, CGI.OperandList[OpNo].Ty));
|
MIOp, OpInfo.Ty));
|
||||||
LastEmitted = VarEnd;
|
LastEmitted = VarEnd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -193,17 +195,20 @@ void AsmWriterEmitter::run(std::ostream &O) {
|
|||||||
|
|
||||||
std::string Namespace = Target.inst_begin()->second.Namespace;
|
std::string Namespace = Target.inst_begin()->second.Namespace;
|
||||||
|
|
||||||
|
std::vector<AsmWriterInst> Instructions;
|
||||||
|
|
||||||
for (CodeGenTarget::inst_iterator I = Target.inst_begin(),
|
for (CodeGenTarget::inst_iterator I = Target.inst_begin(),
|
||||||
E = Target.inst_end(); I != E; ++I)
|
E = Target.inst_end(); I != E; ++I)
|
||||||
if (!I->second.AsmString.empty()) {
|
if (!I->second.AsmString.empty())
|
||||||
O << " case " << Namespace << "::" << I->first << ": ";
|
Instructions.push_back(AsmWriterInst(I->second, Variant));
|
||||||
|
|
||||||
AsmWriterInst AWI;
|
|
||||||
AWI.ParseAsmString(I->second, Variant);
|
|
||||||
AWI.EmitCode(O);
|
|
||||||
O << " break;\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
for (unsigned i = 0, e = Instructions.size(); i != e; ++i) {
|
||||||
|
O << " case " << Namespace << "::"
|
||||||
|
<< Instructions[i].CGI->Name << ": ";
|
||||||
|
Instructions[i].EmitCode(O);
|
||||||
|
O << " break;\n";
|
||||||
|
}
|
||||||
|
|
||||||
O << " }\n"
|
O << " }\n"
|
||||||
" return true;\n"
|
" return true;\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user