mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
[MSP430] Add subtarget features for hardware multiplier.
Also add more processors to make -mcpu option behave similar to gcc. Differential Revision: https://reviews.llvm.org/D33335 llvm-svn: 303695
This commit is contained in:
parent
03923e811e
commit
a328f25e7f
@ -22,6 +22,18 @@ def FeatureX
|
||||
: 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 @@ class Proc<string Name, list<SubtargetFeature> Features>
|
||||
: Processor<Name, NoItineraries, Features>;
|
||||
|
||||
def : Proc<"generic", []>;
|
||||
def : Proc<"msp430", []>;
|
||||
def : Proc<"msp430x", [FeatureX]>;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Register File Description
|
||||
|
@ -38,27 +38,6 @@ using namespace llvm;
|
||||
|
||||
#define DEBUG_TYPE "msp430-lower"
|
||||
|
||||
typedef enum {
|
||||
NoHWMult,
|
||||
HWMult16,
|
||||
HWMult32,
|
||||
HWMultF5
|
||||
} HWMultUseMode;
|
||||
|
||||
static cl::opt<HWMultUseMode>
|
||||
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 @@ MSP430TargetLowering::MSP430TargetLowering(const TargetMachine &TM,
|
||||
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 @@ MSP430TargetLowering::MSP430TargetLowering(const TargetMachine &TM,
|
||||
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 @@ MSP430TargetLowering::MSP430TargetLowering(const TargetMachine &TM,
|
||||
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;
|
||||
|
@ -19,6 +19,20 @@ using namespace llvm;
|
||||
|
||||
#define DEBUG_TYPE "msp430-subtarget"
|
||||
|
||||
static cl::opt<MSP430Subtarget::HWMultEnum>
|
||||
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 @@ void MSP430Subtarget::anchor() { }
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -30,8 +30,15 @@ namespace llvm {
|
||||
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 @@ public:
|
||||
/// 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;
|
||||
}
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user