X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FTarget%2FSparcV9%2FSparcV9InstrInfo.cpp;h=fbabe933166403fd398b74121e04629c2c729d93;hb=b7551ef115cc25d9abc87cabf67ad1717c8e69c9;hp=993f2a2ffa131312f87e767644470d768d8693bc;hpb=5cededee9217804de91a5a55c9e38df06a239a4e;p=oota-llvm.git diff --git a/lib/Target/SparcV9/SparcV9InstrInfo.cpp b/lib/Target/SparcV9/SparcV9InstrInfo.cpp index 993f2a2ffa1..fbabe933166 100644 --- a/lib/Target/SparcV9/SparcV9InstrInfo.cpp +++ b/lib/Target/SparcV9/SparcV9InstrInfo.cpp @@ -6,7 +6,7 @@ #include "SparcInstrSelectionSupport.h" #include "llvm/CodeGen/InstrSelection.h" #include "llvm/CodeGen/InstrSelectionSupport.h" -#include "llvm/CodeGen/MachineCodeForMethod.h" +#include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineCodeForInstruction.h" #include "llvm/Function.h" #include "llvm/Constants.h" @@ -266,15 +266,15 @@ CreateIntSetInstruction(const TargetMachine& target, // Entry == 0 ==> no immediate constant field exists at all. // Entry > 0 ==> abs(immediate constant) <= Entry // -vector MaxConstantsTable(Instruction::NumOtherOps); +vector MaxConstantsTable(Instruction::OtherOpsEnd); static int MaxConstantForInstr(unsigned llvmOpCode) { int modelOpCode = -1; - if (llvmOpCode >= Instruction::FirstBinaryOp && - llvmOpCode < Instruction::NumBinaryOps) + if (llvmOpCode >= Instruction::BinaryOpsBegin && + llvmOpCode < Instruction::BinaryOpsEnd) modelOpCode = ADD; else switch(llvmOpCode) { @@ -300,15 +300,15 @@ static void InitializeMaxConstantsTable() { unsigned op; - assert(MaxConstantsTable.size() == Instruction::NumOtherOps && + assert(MaxConstantsTable.size() == Instruction::OtherOpsEnd && "assignments below will be illegal!"); - for (op = Instruction::FirstTermOp; op < Instruction::NumTermOps; ++op) + for (op = Instruction::TermOpsBegin; op < Instruction::TermOpsEnd; ++op) MaxConstantsTable[op] = MaxConstantForInstr(op); - for (op = Instruction::FirstBinaryOp; op < Instruction::NumBinaryOps; ++op) + for (op = Instruction::BinaryOpsBegin; op < Instruction::BinaryOpsEnd; ++op) MaxConstantsTable[op] = MaxConstantForInstr(op); - for (op = Instruction::FirstMemoryOp; op < Instruction::NumMemoryOps; ++op) + for (op = Instruction::MemoryOpsBegin; op < Instruction::MemoryOpsEnd; ++op) MaxConstantsTable[op] = MaxConstantForInstr(op); - for (op = Instruction::FirstOtherOp; op < Instruction::NumOtherOps; ++op) + for (op = Instruction::OtherOpsBegin; op < Instruction::OtherOpsEnd; ++op) MaxConstantsTable[op] = MaxConstantForInstr(op); } @@ -343,13 +343,14 @@ UltraSparcInstrInfo::ConstantMayNotFitInImmedField(const Constant* CV, return false; if (const ConstantUInt* U = dyn_cast(CV)) - return (U->getValue() > MaxConstantsTable[I->getOpcode()]); + /* Large unsigned longs may really just be small negative signed longs */ + return (labs((int64_t) U->getValue()) > MaxConstantsTable[I->getOpcode()]); if (const ConstantSInt* S = dyn_cast(CV)) - return (labs(S->getValue()) > (int) MaxConstantsTable[I->getOpcode()]); + return (labs(S->getValue()) > MaxConstantsTable[I->getOpcode()]); if (isa(CV)) - return (1U > MaxConstantsTable[I->getOpcode()]); + return (1 > MaxConstantsTable[I->getOpcode()]); return true; } @@ -360,7 +361,7 @@ UltraSparcInstrInfo::ConstantMayNotFitInImmedField(const Constant* CV, // GlobalValue, viz., the constant address of a global variable or function. // The generated instructions are returned in `mvec'. // Any temp. registers (TmpInstruction) created are recorded in mcfi. -// Any stack space required is allocated via MachineCodeForMethod. +// Any stack space required is allocated via MachineFunction. // void UltraSparcInstrInfo::CreateCodeToLoadConst(const TargetMachine& target, @@ -380,6 +381,11 @@ UltraSparcInstrInfo::CreateCodeToLoadConst(const TargetMachine& target, // const Type* valType = val->getType(); + // Unfortunate special case: a ConstantPointerRef is just a + // reference to GlobalValue. + if (isa(val)) + val = cast(val)->getValue(); + if (isa(val)) { TmpInstruction* tmpReg = @@ -455,7 +461,7 @@ UltraSparcInstrInfo::CreateCodeToLoadConst(const TargetMachine& target, mvec.push_back(MI); // Make sure constant is emitted to constant pool in assembly code. - MachineCodeForMethod::get(F).addToConstantPool(cast(val)); + MachineFunction::get(F).addToConstantPool(cast(val)); } } @@ -465,7 +471,7 @@ UltraSparcInstrInfo::CreateCodeToLoadConst(const TargetMachine& target, // val must be an integral type. dest must be a Float or Double. // The generated instructions are returned in `mvec'. // Any temp. registers (TmpInstruction) created are recorded in mcfi. -// Any stack space required is allocated via MachineCodeForMethod. +// Any stack space required is allocated via MachineFunction. // void UltraSparcInstrInfo::CreateCodeToCopyIntToFloat(const TargetMachine& target, @@ -481,7 +487,7 @@ UltraSparcInstrInfo::CreateCodeToCopyIntToFloat(const TargetMachine& target, && "Dest type must be float/double"); // Get a stack slot to use for the copy - int offset = MachineCodeForMethod::get(F).allocateLocalVar(target, val); + int offset = MachineFunction::get(F).allocateLocalVar(target, val); // Get the size of the source value being copied. size_t srcSize = target.DataLayout.getTypeSize(val->getType()); @@ -526,7 +532,7 @@ UltraSparcInstrInfo::CreateCodeToCopyIntToFloat(const TargetMachine& target, // `val' to an integer register `dest' by copying to memory and back. // The generated instructions are returned in `mvec'. // Any temp. registers (TmpInstruction) created are recorded in mcfi. -// Any stack space required is allocated via MachineCodeForMethod. +// Any stack space required is allocated via MachineFunction. // void UltraSparcInstrInfo::CreateCodeToCopyFloatToInt(const TargetMachine& target, @@ -543,7 +549,7 @@ UltraSparcInstrInfo::CreateCodeToCopyFloatToInt(const TargetMachine& target, assert((destTy->isIntegral() || isa(destTy)) && "Dest type must be integer, bool or pointer"); - int offset = MachineCodeForMethod::get(F).allocateLocalVar(target, val); + int offset = MachineFunction::get(F).allocateLocalVar(target, val); // Store instruction stores `val' to [%fp+offset]. // The store opCode is based only the source value being copied. @@ -573,7 +579,7 @@ UltraSparcInstrInfo::CreateCodeToCopyFloatToInt(const TargetMachine& target, // Create instruction(s) to copy src to dest, for arbitrary types // The generated instructions are returned in `mvec'. // Any temp. registers (TmpInstruction) created are recorded in mcfi. -// Any stack space required is allocated via MachineCodeForMethod. +// Any stack space required is allocated via MachineFunction. // void UltraSparcInstrInfo::CreateCopyInstructionsByType(const TargetMachine& target, @@ -669,7 +675,7 @@ CreateBitExtensionInstructions(bool signExtend, // from an arbitrary-sized integer value (sized in bits, not bytes). // The generated instructions are returned in `mvec'. // Any temp. registers (TmpInstruction) created are recorded in mcfi. -// Any stack space required is allocated via MachineCodeForMethod. +// Any stack space required is allocated via MachineFunction. // void UltraSparcInstrInfo::CreateSignExtensionInstructions( @@ -691,7 +697,7 @@ UltraSparcInstrInfo::CreateSignExtensionInstructions( // For SPARC v9, we sign-extend the given operand using SLL; SRL. // The generated instructions are returned in `mvec'. // Any temp. registers (TmpInstruction) created are recorded in mcfi. -// Any stack space required is allocated via MachineCodeForMethod. +// Any stack space required is allocated via MachineFunction. // void UltraSparcInstrInfo::CreateZeroExtensionInstructions(