aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/SparcV9/SparcV9InstrSelectionSupport.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Target/SparcV9/SparcV9InstrSelectionSupport.h')
-rw-r--r--lib/Target/SparcV9/SparcV9InstrSelectionSupport.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/Target/SparcV9/SparcV9InstrSelectionSupport.h b/lib/Target/SparcV9/SparcV9InstrSelectionSupport.h
index 848dddd..2ee9294 100644
--- a/lib/Target/SparcV9/SparcV9InstrSelectionSupport.h
+++ b/lib/Target/SparcV9/SparcV9InstrSelectionSupport.h
@@ -12,6 +12,8 @@
#ifndef SPARC_INSTR_SELECTION_SUPPORT_h
#define SPARC_INSTR_SELECTION_SUPPORT_h
+#include "llvm/DerivedTypes.h"
+#include "llvm/Value.h"
inline MachineOpCode
ChooseLoadInstruction(const Type *DestTy)
@@ -58,4 +60,29 @@ ChooseStoreInstruction(const Type *DestTy)
return 0;
}
+
+inline MachineOpCode
+ChooseAddInstructionByType(const Type* resultType)
+{
+ MachineOpCode opCode = INVALID_OPCODE;
+
+ if (resultType->isIntegral() ||
+ isa<PointerType>(resultType) ||
+ isa<FunctionType>(resultType) ||
+ resultType == Type::LabelTy ||
+ resultType == Type::BoolTy)
+ {
+ opCode = ADD;
+ }
+ else
+ switch(resultType->getPrimitiveID())
+ {
+ case Type::FloatTyID: opCode = FADDS; break;
+ case Type::DoubleTyID: opCode = FADDD; break;
+ default: assert(0 && "Invalid type for ADD instruction"); break;
+ }
+
+ return opCode;
+}
+
#endif