+
+inline MachineOpCode
+ChooseAddInstructionByType(const Type* resultType)
+{
+ MachineOpCode opCode = INVALID_OPCODE;
+
+ if (resultType->isIntegral() ||
+ isa<PointerType>(resultType) ||
+ isa<FunctionType>(resultType) ||
+ resultType == Type::LabelTy)
+ {
+ 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;
+}
+