Use BranchProbability instead of floating points in IfConverter.
[llvm/stm8.git] / lib / Target / ARM / MCTargetDesc / ARMMCTargetDesc.cpp
blob1139cac3949d8c10b4888fa9d466a43c502e2600
1 //===-- ARMMCTargetDesc.cpp - ARM Target Descriptions -----------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file provides ARM specific target descriptions.
12 //===----------------------------------------------------------------------===//
14 #include "ARMMCTargetDesc.h"
15 #include "llvm/MC/MCInstrInfo.h"
16 #include "llvm/MC/MCRegisterInfo.h"
17 #include "llvm/MC/MCSubtargetInfo.h"
18 #include "llvm/Target/TargetRegistry.h"
20 #define GET_REGINFO_MC_DESC
21 #include "ARMGenRegisterInfo.inc"
23 #define GET_INSTRINFO_MC_DESC
24 #include "ARMGenInstrInfo.inc"
26 #define GET_SUBTARGETINFO_ENUM
27 #define GET_SUBTARGETINFO_MC_DESC
28 #include "ARMGenSubtargetInfo.inc"
30 using namespace llvm;
32 std::string ARM_MC::ParseARMTriple(StringRef TT) {
33 // Set the boolean corresponding to the current target triple, or the default
34 // if one cannot be determined, to true.
35 unsigned Len = TT.size();
36 unsigned Idx = 0;
38 // FIXME: Enahnce Triple helper class to extract ARM version.
39 bool isThumb = false;
40 if (Len >= 5 && TT.substr(0, 4) == "armv")
41 Idx = 4;
42 else if (Len >= 6 && TT.substr(0, 5) == "thumb") {
43 isThumb = true;
44 if (Len >= 7 && TT[5] == 'v')
45 Idx = 6;
48 std::string ARMArchFeature;
49 if (Idx) {
50 unsigned SubVer = TT[Idx];
51 if (SubVer >= '7' && SubVer <= '9') {
52 if (Len >= Idx+2 && TT[Idx+1] == 'm') {
53 // v7m: FeatureNoARM, FeatureDB, FeatureHWDiv
54 ARMArchFeature = "+v7,+noarm,+db,+hwdiv";
55 } else if (Len >= Idx+3 && TT[Idx+1] == 'e'&& TT[Idx+2] == 'm') {
56 // v7em: FeatureNoARM, FeatureDB, FeatureHWDiv, FeatureDSPThumb2,
57 // FeatureT2XtPk
58 ARMArchFeature = "+v7,+noarm,+db,+hwdiv,+t2dsp,t2xtpk";
59 } else
60 // v7a: FeatureNEON, FeatureDB, FeatureDSPThumb2
61 ARMArchFeature = "+v7,+neon,+db,+t2dsp";
62 } else if (SubVer == '6') {
63 if (Len >= Idx+3 && TT[Idx+1] == 't' && TT[Idx+2] == '2')
64 ARMArchFeature = "+v6t2";
65 else
66 ARMArchFeature = "+v6";
67 } else if (SubVer == '5') {
68 if (Len >= Idx+3 && TT[Idx+1] == 't' && TT[Idx+2] == 'e')
69 ARMArchFeature = "+v5te";
70 else
71 ARMArchFeature = "+v5t";
72 } else if (SubVer == '4' && Len >= Idx+2 && TT[Idx+1] == 't')
73 ARMArchFeature = "+v4t";
76 if (isThumb) {
77 if (ARMArchFeature.empty())
78 ARMArchFeature = "+thumb-mode";
79 else
80 ARMArchFeature += ",+thumb-mode";
83 return ARMArchFeature;
86 MCSubtargetInfo *ARM_MC::createARMMCSubtargetInfo(StringRef TT, StringRef CPU,
87 StringRef FS) {
88 std::string ArchFS = ARM_MC::ParseARMTriple(TT);
89 if (!FS.empty()) {
90 if (!ArchFS.empty())
91 ArchFS = ArchFS + "," + FS.str();
92 else
93 ArchFS = FS;
96 MCSubtargetInfo *X = new MCSubtargetInfo();
97 InitARMMCSubtargetInfo(X, CPU, ArchFS);
98 return X;
101 MCInstrInfo *createARMMCInstrInfo() {
102 MCInstrInfo *X = new MCInstrInfo();
103 InitARMMCInstrInfo(X);
104 return X;
107 MCRegisterInfo *createARMMCRegisterInfo() {
108 MCRegisterInfo *X = new MCRegisterInfo();
109 InitARMMCRegisterInfo(X);
110 return X;
113 // Force static initialization.
114 extern "C" void LLVMInitializeARMMCInstrInfo() {
115 TargetRegistry::RegisterMCInstrInfo(TheARMTarget, createARMMCInstrInfo);
116 TargetRegistry::RegisterMCInstrInfo(TheThumbTarget, createARMMCInstrInfo);
119 extern "C" void LLVMInitializeARMMCRegInfo() {
120 TargetRegistry::RegisterMCRegInfo(TheARMTarget, createARMMCRegisterInfo);
121 TargetRegistry::RegisterMCRegInfo(TheThumbTarget, createARMMCRegisterInfo);
124 extern "C" void LLVMInitializeARMMCSubtargetInfo() {
125 TargetRegistry::RegisterMCSubtargetInfo(TheARMTarget,
126 ARM_MC::createARMMCSubtargetInfo);
127 TargetRegistry::RegisterMCSubtargetInfo(TheThumbTarget,
128 ARM_MC::createARMMCSubtargetInfo);