From ca4f6ebefc4dc55d13a0182a0be5b02e92fc63ea Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 15 Oct 2004 04:38:41 +0000 Subject: Allow machine operands to represent global variables with offsets. This is useful when you have a reference like: int A[100]; void foo() { A[10] = 1; } In this case, &A[10] is a single constant and should be treated as such. Only MO_GlobalAddress and MO_ExternalSymbol are allowed to use this field, no other operand type is. This is another fine patch contributed by Jeff Cohen!! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17007 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/MachineInstr.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'lib/CodeGen/MachineInstr.cpp') diff --git a/lib/CodeGen/MachineInstr.cpp b/lib/CodeGen/MachineInstr.cpp index a4ae09a649..3dce6fc85d 100644 --- a/lib/CodeGen/MachineInstr.cpp +++ b/lib/CodeGen/MachineInstr.cpp @@ -127,7 +127,7 @@ void MachineInstr::SetMachineOperandVal(unsigned i, assert(i < operands.size()); // may be explicit or implicit op operands[i].opType = opTy; operands[i].contents.value = V; - operands[i].regNum = -1; + operands[i].extra.regNum = -1; } void @@ -141,7 +141,7 @@ MachineInstr::SetMachineOperandConst(unsigned i, operands[i].opType = opTy; operands[i].contents.value = NULL; operands[i].contents.immedVal = intValue; - operands[i].regNum = -1; + operands[i].extra.regNum = -1; operands[i].flags = 0; } @@ -150,7 +150,7 @@ void MachineInstr::SetMachineOperandReg(unsigned i, int regNum) { operands[i].opType = MachineOperand::MO_MachineRegister; operands[i].contents.value = NULL; - operands[i].regNum = regNum; + operands[i].extra.regNum = regNum; } // Used only by the SPARC back-end. @@ -302,10 +302,14 @@ static void print(const MachineOperand &MO, std::ostream &OS, OS << ""; break; case MachineOperand::MO_GlobalAddress: - OS << "getName() << ">"; + OS << "getName(); + if (MO.getOffset()) OS << "+" << MO.getOffset(); + OS << ">"; break; case MachineOperand::MO_ExternalSymbol: - OS << ""; + OS << ""; break; default: assert(0 && "Unrecognized operand type"); -- cgit v1.2.3-18-g5258