From: Daniel Dunbar Date: Sun, 2 Aug 2009 00:09:22 +0000 (+0000) Subject: Change MCOperand to use Create style instead of Make style for constructing X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=cdcb388a589846e7e7ca8c88f77cf53933539074;p=oota-llvm.git Change MCOperand to use Create style instead of Make style for constructing operands. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77837 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/MC/MCInst.h b/include/llvm/MC/MCInst.h index 8b638d4c743..36011b9b65f 100644 --- a/include/llvm/MC/MCInst.h +++ b/include/llvm/MC/MCInst.h @@ -94,22 +94,30 @@ public: MCValueVal = Val; } - void MakeReg(unsigned Reg) { - Kind = kRegister; - RegVal = Reg; + static MCOperand CreateReg(unsigned Reg) { + MCOperand Op; + Op.Kind = kRegister; + Op.RegVal = Reg; + return Op; } - void MakeImm(int64_t Val) { - Kind = kImmediate; - ImmVal = Val; + static MCOperand CreateImm(int64_t Val) { + MCOperand Op; + Op.Kind = kImmediate; + Op.ImmVal = Val; + return Op; } - void MakeMBBLabel(unsigned Fn, unsigned MBB) { - Kind = kMBBLabel; - MBBLabel.FunctionNo = Fn; - MBBLabel.BlockNo = MBB; + static MCOperand CreateMBBLabel(unsigned Fn, unsigned MBB) { + MCOperand Op; + Op.Kind = kMBBLabel; + Op.MBBLabel.FunctionNo = Fn; + Op.MBBLabel.BlockNo = MBB; + return Op; } - void MakeMCValue(const MCValue &Val) { - Kind = kMCValue; - MCValueVal = Val; + static MCOperand CreateMCValue(const MCValue &Val) { + MCOperand Op; + Op.Kind = kMCValue; + Op.MCValueVal = Val; + return Op; } }; diff --git a/lib/Target/X86/AsmParser/X86AsmParser.cpp b/lib/Target/X86/AsmParser/X86AsmParser.cpp index db52c118ea3..4d7358ab584 100644 --- a/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ b/lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -372,7 +372,7 @@ Match_X86_Op_REG(const X86Operand &Op, MCOperand *MCOps, unsigned NumOps) { if (Op.Kind != X86Operand::Register) return true; - MCOps[0].MakeReg(Op.getReg()); + MCOps[0] = MCOperand::CreateReg(Op.getReg()); return false; } @@ -384,7 +384,7 @@ Match_X86_Op_IMM(const X86Operand &Op, MCOperand *MCOps, unsigned NumOps) { if (Op.Kind != X86Operand::Immediate) return true; - MCOps[0].MakeMCValue(Op.getImm()); + MCOps[0] = MCOperand::CreateMCValue(Op.getImm()); return false; } @@ -396,10 +396,10 @@ static bool Match_X86_Op_LMEM(const X86Operand &Op, if (Op.Kind != X86Operand::Memory) return true; - MCOps[0].MakeReg(Op.getMemBaseReg()); - MCOps[1].MakeImm(Op.getMemScale()); - MCOps[2].MakeReg(Op.getMemIndexReg()); - MCOps[3].MakeMCValue(Op.getMemDisp()); + MCOps[0] = MCOperand::CreateReg(Op.getMemBaseReg()); + MCOps[1] = MCOperand::CreateImm(Op.getMemScale()); + MCOps[2] = MCOperand::CreateReg(Op.getMemIndexReg()); + MCOps[3] = MCOperand::CreateMCValue(Op.getMemDisp()); return false; } @@ -412,7 +412,7 @@ static bool Match_X86_Op_MEM(const X86Operand &Op, if (Match_X86_Op_LMEM(Op, MCOps, 4)) return true; - MCOps[4].MakeReg(Op.getMemSegReg()); + MCOps[4] = MCOperand::CreateReg(Op.getMemSegReg()); return false; } diff --git a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp index a4b36a0fb34..9b73e87cc67 100644 --- a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp +++ b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp @@ -725,11 +725,12 @@ void X86ATTAsmPrinter::printMachineInstruction(const MachineInstr *MI) { MCOperand MCOp; if (MO.isReg()) { - MCOp.MakeReg(MO.getReg()); + MCOp = MCOperand::CreateReg(MO.getReg()); } else if (MO.isImm()) { - MCOp.MakeImm(MO.getImm()); + MCOp = MCOperand::CreateImm(MO.getImm()); } else if (MO.isMBB()) { - MCOp.MakeMBBLabel(getFunctionNumber(), MO.getMBB()->getNumber()); + MCOp = MCOperand::CreateMBBLabel(getFunctionNumber(), + MO.getMBB()->getNumber()); } else { llvm_unreachable("Unimp"); } diff --git a/utils/TableGen/AsmMatcherEmitter.cpp b/utils/TableGen/AsmMatcherEmitter.cpp index 611d470a46d..74269a44e29 100644 --- a/utils/TableGen/AsmMatcherEmitter.cpp +++ b/utils/TableGen/AsmMatcherEmitter.cpp @@ -258,7 +258,7 @@ void AsmMatcherEmitter::run(raw_ostream &OS) { if (!MatchedOperands.count(i)) { OS << "\n"; OS << " // FIXME: Nothing matched Ops[" << i << "]!\n"; - OS << " Ops[" << i << "].MakeReg(0);\n"; + OS << " Ops[" << i << "] = MCOperand::CreateReg(0);\n"; OS << "\n"; }