Index: llvm/trunk/lib/Target/MSP430/MSP430.td =================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430.td +++ llvm/trunk/lib/Target/MSP430/MSP430.td @@ -22,6 +22,18 @@ : SubtargetFeature<"ext", "ExtendedInsts", "true", "Enable MSP430-X extensions">; +def FeatureHWMult16 + : SubtargetFeature<"hwmult16", "HWMultMode", "HWMult16", + "Enable 16-bit hardware multiplier">; + +def FeatureHWMult32 + : SubtargetFeature<"hwmult32", "HWMultMode", "HWMult32", + "Enable 32-bit hardware multiplier">; + +def FeatureHWMultF5 + : SubtargetFeature<"hwmultf5", "HWMultMode", "HWMultF5", + "Enable F5 series hardware multiplier">; + //===----------------------------------------------------------------------===// // MSP430 supported processors. //===----------------------------------------------------------------------===// @@ -29,6 +41,8 @@ : Processor; def : Proc<"generic", []>; +def : Proc<"msp430", []>; +def : Proc<"msp430x", [FeatureX]>; //===----------------------------------------------------------------------===// // Register File Description Index: llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp =================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp +++ llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp @@ -38,27 +38,6 @@ #define DEBUG_TYPE "msp430-lower" -typedef enum { - NoHWMult, - HWMult16, - HWMult32, - HWMultF5 -} HWMultUseMode; - -static cl::opt -HWMultMode("mhwmult", cl::Hidden, - cl::desc("Hardware multiplier use mode"), - cl::init(NoHWMult), - cl::values( - clEnumValN(NoHWMult, "none", - "Do not use hardware multiplier"), - clEnumValN(HWMult16, "16bit", - "Use 16-bit hardware multiplier"), - clEnumValN(HWMult32, "32bit", - "Use 32-bit hardware multiplier"), - clEnumValN(HWMultF5, "f5series", - "Use F5 series hardware multiplier"))); - MSP430TargetLowering::MSP430TargetLowering(const TargetMachine &TM, const MSP430Subtarget &STI) : TargetLowering(TM) { @@ -262,7 +241,7 @@ setCmpLibcallCC(LC.Op, LC.Cond); } - if (HWMultMode == HWMult16) { + if (STI.hasHWMult16()) { const struct { const RTLIB::Libcall Op; const char * const Name; @@ -277,7 +256,7 @@ for (const auto &LC : LibraryCalls) { setLibcallName(LC.Op, LC.Name); } - } else if (HWMultMode == HWMult32) { + } else if (STI.hasHWMult32()) { const struct { const RTLIB::Libcall Op; const char * const Name; @@ -292,7 +271,7 @@ for (const auto &LC : LibraryCalls) { setLibcallName(LC.Op, LC.Name); } - } else if (HWMultMode == HWMultF5) { + } else if (STI.hasHWMultF5()) { const struct { const RTLIB::Libcall Op; const char * const Name; Index: llvm/trunk/lib/Target/MSP430/MSP430Subtarget.h =================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430Subtarget.h +++ llvm/trunk/lib/Target/MSP430/MSP430Subtarget.h @@ -30,8 +30,15 @@ class StringRef; class MSP430Subtarget : public MSP430GenSubtargetInfo { +public: + enum HWMultEnum { + NoHWMult, HWMult16, HWMult32, HWMultF5 + }; + +private: virtual void anchor(); bool ExtendedInsts; + HWMultEnum HWMultMode; MSP430FrameLowering FrameLowering; MSP430InstrInfo InstrInfo; MSP430TargetLowering TLInfo; @@ -50,6 +57,10 @@ /// subtarget options. Definition of function is auto generated by tblgen. void ParseSubtargetFeatures(StringRef CPU, StringRef FS); + bool hasHWMult16() const { return HWMultMode == HWMult16; } + bool hasHWMult32() const { return HWMultMode == HWMult32; } + bool hasHWMultF5() const { return HWMultMode == HWMultF5; } + const TargetFrameLowering *getFrameLowering() const override { return &FrameLowering; } Index: llvm/trunk/lib/Target/MSP430/MSP430Subtarget.cpp =================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430Subtarget.cpp +++ llvm/trunk/lib/Target/MSP430/MSP430Subtarget.cpp @@ -19,6 +19,20 @@ #define DEBUG_TYPE "msp430-subtarget" +static cl::opt +HWMultModeOption("mhwmult", cl::Hidden, + cl::desc("Hardware multiplier use mode for MSP430"), + cl::init(MSP430Subtarget::NoHWMult), + cl::values( + clEnumValN(MSP430Subtarget::NoHWMult, "none", + "Do not use hardware multiplier"), + clEnumValN(MSP430Subtarget::HWMult16, "16bit", + "Use 16-bit hardware multiplier"), + clEnumValN(MSP430Subtarget::HWMult32, "32bit", + "Use 32-bit hardware multiplier"), + clEnumValN(MSP430Subtarget::HWMultF5, "f5series", + "Use F5 series hardware multiplier"))); + #define GET_SUBTARGETINFO_TARGET_DESC #define GET_SUBTARGETINFO_CTOR #include "MSP430GenSubtargetInfo.inc" @@ -27,7 +41,18 @@ MSP430Subtarget & MSP430Subtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) { - ParseSubtargetFeatures("generic", FS); + ExtendedInsts = false; + HWMultMode = NoHWMult; + + std::string CPUName = CPU; + if (CPUName.empty()) + CPUName = "msp430"; + + ParseSubtargetFeatures(CPUName, FS); + + if (HWMultModeOption != NoHWMult) + HWMultMode = HWMultModeOption; + return *this; } Index: llvm/trunk/test/CodeGen/MSP430/hwmult16.ll =================================================================== --- llvm/trunk/test/CodeGen/MSP430/hwmult16.ll +++ llvm/trunk/test/CodeGen/MSP430/hwmult16.ll @@ -1,4 +1,5 @@ ; RUN: llc -O0 -mhwmult=16bit < %s | FileCheck %s +; RUN: llc -O0 -mattr=+hwmult16 < %s | FileCheck %s target datalayout = "e-p:16:16:16-i8:8:8-i16:16:16-i32:16:32-n8:16-a0:16:16" target triple = "msp430---elf" Index: llvm/trunk/test/CodeGen/MSP430/hwmult32.ll =================================================================== --- llvm/trunk/test/CodeGen/MSP430/hwmult32.ll +++ llvm/trunk/test/CodeGen/MSP430/hwmult32.ll @@ -1,4 +1,5 @@ ; RUN: llc -O0 -mhwmult=32bit < %s | FileCheck %s +; RUN: llc -O0 -mattr=+hwmult32 < %s | FileCheck %s target datalayout = "e-p:16:16:16-i8:8:8-i16:16:16-i32:16:32-n8:16-a0:16:16" target triple = "msp430---elf" Index: llvm/trunk/test/CodeGen/MSP430/hwmultf5.ll =================================================================== --- llvm/trunk/test/CodeGen/MSP430/hwmultf5.ll +++ llvm/trunk/test/CodeGen/MSP430/hwmultf5.ll @@ -1,4 +1,5 @@ ; RUN: llc -O0 -mhwmult=f5series < %s | FileCheck %s +; RUN: llc -O0 -mattr=+hwmultf5 < %s | FileCheck %s target datalayout = "e-p:16:16:16-i8:8:8-i16:16:16-i32:16:32-n8:16-a0:16:16" target triple = "msp430---elf"