summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/SparcV9
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Target/SparcV9')
-rw-r--r--llvm/lib/Target/SparcV9/InstrSelection/InstrForest.cpp10
-rw-r--r--llvm/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp19
-rw-r--r--llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp26
-rw-r--r--llvm/lib/Target/SparcV9/SparcV9PreSelection.cpp2
4 files changed, 26 insertions, 31 deletions
diff --git a/llvm/lib/Target/SparcV9/InstrSelection/InstrForest.cpp b/llvm/lib/Target/SparcV9/InstrSelection/InstrForest.cpp
index cc22b3774a1..271857b80ad 100644
--- a/llvm/lib/Target/SparcV9/InstrSelection/InstrForest.cpp
+++ b/llvm/lib/Target/SparcV9/InstrSelection/InstrForest.cpp
@@ -244,8 +244,7 @@ InstructionNode* InstrForest::buildTreeForInstruction(Instruction *instr) {
&& !instr->isTerminator();
if (includeAddressOperand || isa<Instruction>(operand) ||
- isa<Constant>(operand) || isa<Argument>(operand) ||
- isa<GlobalVariable>(operand))
+ isa<Constant>(operand) || isa<Argument>(operand))
{
// This operand is a data value
@@ -273,8 +272,11 @@ InstructionNode* InstrForest::buildTreeForInstruction(Instruction *instr) {
// Recursively create a treeNode for it.
opTreeNode = buildTreeForInstruction((Instruction*)operand);
} else if (Constant *CPV = dyn_cast<Constant>(operand)) {
- // Create a leaf node for a constant
- opTreeNode = new ConstantNode(CPV);
+ if (isa<GlobalValue>(CPV))
+ opTreeNode = new VRegNode(operand);
+ else
+ // Create a leaf node for a constant
+ opTreeNode = new ConstantNode(CPV);
} else {
// Create a leaf node for the virtual register
opTreeNode = new VRegNode(operand);
diff --git a/llvm/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp b/llvm/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp
index e0f43b529bf..7e0f6c48c6d 100644
--- a/llvm/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp
+++ b/llvm/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp
@@ -22,6 +22,7 @@
#include "llvm/Constants.h"
#include "llvm/BasicBlock.h"
#include "llvm/DerivedTypes.h"
+#include "llvm/GlobalValue.h"
#include "../SparcV9InstrSelectionSupport.h"
namespace llvm {
@@ -159,13 +160,14 @@ FixConstantOperandsForInstr(Instruction* vmInstr,
if (mop.getType() == MachineOperand::MO_VirtualRegister) {
assert(mop.getVRegValue() != NULL);
opValue = mop.getVRegValue();
- if (Constant *opConst = dyn_cast<Constant>(opValue)) {
- opType = ChooseRegOrImmed(opConst, opCode, target,
- (immedPos == (int)op), machineRegNum,
- immedValue);
- if (opType == MachineOperand::MO_VirtualRegister)
- constantThatMustBeLoaded = true;
- }
+ if (Constant *opConst = dyn_cast<Constant>(opValue))
+ if (!isa<GlobalValue>(opConst)) {
+ opType = ChooseRegOrImmed(opConst, opCode, target,
+ (immedPos == (int)op), machineRegNum,
+ immedValue);
+ if (opType == MachineOperand::MO_VirtualRegister)
+ constantThatMustBeLoaded = true;
+ }
} else {
//
// If the operand is from the constant pool, don't try to change it.
@@ -242,8 +244,7 @@ FixConstantOperandsForInstr(Instruction* vmInstr,
argDesc = CallArgsDescriptor::get(minstr);
for (unsigned i=0, N=minstr->getNumImplicitRefs(); i < N; ++i)
- if (isa<Constant>(minstr->getImplicitRef(i)) ||
- isa<GlobalValue>(minstr->getImplicitRef(i)))
+ if (isa<Constant>(minstr->getImplicitRef(i)))
{
Value* oldVal = minstr->getImplicitRef(i);
TmpInstruction* tmpReg =
diff --git a/llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp b/llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp
index 986d4a88b3e..30d35546e6c 100644
--- a/llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp
+++ b/llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp
@@ -56,16 +56,14 @@ SparcV9InstrInfo::ConvertConstantToIntType(const TargetMachine &target,
if (! destType->isIntegral() && ! isa<PointerType>(destType))
return C;
- if (! isa<Constant>(V))
+ if (! isa<Constant>(V) || isa<GlobalValue>(V))
return C;
- // ConstantPointerRef: no conversions needed: get value and return it
- if (const ConstantPointerRef* CPR = dyn_cast<ConstantPointerRef>(V)) {
- // A ConstantPointerRef is just a reference to GlobalValue.
+ // GlobalValue: no conversions needed: get value and return it
+ if (const GlobalValue* GV = dyn_cast<GlobalValue>(V)) {
isValidConstant = true; // may be overwritten by recursive call
- return (CPR->isNullValue()? 0
- : ConvertConstantToIntType(target, CPR->getValue(), destType,
- isValidConstant));
+ return GV->isNullValue() ? 0 :
+ ConvertConstantToIntType(target, GV, destType, isValidConstant);
}
// ConstantBool: no conversions needed: get value and return it
@@ -284,7 +282,7 @@ CreateSETXLabel(const TargetMachine& target,
Value* val, Instruction* tmpReg, Instruction* dest,
std::vector<MachineInstr*>& mvec)
{
- assert(isa<Constant>(val) || isa<GlobalValue>(val) &&
+ assert(isa<Constant>(val) &&
"I only know about constant values and global addresses");
MachineInstr* MI;
@@ -467,7 +465,7 @@ SparcV9InstrInfo::CreateCodeToLoadConst(const TargetMachine& target,
std::vector<MachineInstr*>& mvec,
MachineCodeForInstruction& mcfi) const
{
- assert(isa<Constant>(val) || isa<GlobalValue>(val) &&
+ assert(isa<Constant>(val) &&
"I only know about constant values and global addresses");
// Use a "set" instruction for known constants or symbolic constants (labels)
@@ -477,10 +475,6 @@ SparcV9InstrInfo::CreateCodeToLoadConst(const TargetMachine& target,
//
const Type* valType = val->getType();
- // A ConstantPointerRef is just a reference to GlobalValue.
- while (isa<ConstantPointerRef>(val))
- val = cast<ConstantPointerRef>(val)->getValue();
-
if (isa<GlobalValue>(val)) {
TmpInstruction* tmpReg =
new TmpInstruction(mcfi, PointerType::get(val->getType()), val);
@@ -688,7 +682,9 @@ SparcV9InstrInfo::CreateCopyInstructionsByType(const TargetMachine& target,
// a global variable (i.e., a constant address), generate a load
// instruction instead of an add
//
- if (isa<Constant>(src)) {
+ if (isa<GlobalValue>(src))
+ loadConstantToReg = true;
+ else if (isa<Constant>(src)) {
unsigned int machineRegNum;
int64_t immedValue;
MachineOperand::MachineOperandType opType =
@@ -698,8 +694,6 @@ SparcV9InstrInfo::CreateCopyInstructionsByType(const TargetMachine& target,
if (opType == MachineOperand::MO_VirtualRegister)
loadConstantToReg = true;
}
- else if (isa<GlobalValue>(src))
- loadConstantToReg = true;
if (loadConstantToReg) {
// `src' is constant and cannot fit in immed field for the ADD
diff --git a/llvm/lib/Target/SparcV9/SparcV9PreSelection.cpp b/llvm/lib/Target/SparcV9/SparcV9PreSelection.cpp
index 00cfd1295e6..fc629a6a3fd 100644
--- a/llvm/lib/Target/SparcV9/SparcV9PreSelection.cpp
+++ b/llvm/lib/Target/SparcV9/SparcV9PreSelection.cpp
@@ -85,8 +85,6 @@ namespace {
// getGlobalAddr(): Put address of a global into a v. register.
static GetElementPtrInst* getGlobalAddr(Value* ptr, Instruction& insertBefore) {
- if (isa<ConstantPointerRef>(ptr))
- ptr = cast<ConstantPointerRef>(ptr)->getValue();
return (isa<GlobalVariable>(ptr))
? new GetElementPtrInst(ptr,
OpenPOWER on IntegriCloud