Sort the cpu and features table, so that the alpha backend doesn't fail EVERY
[oota-llvm.git] / lib / Target / Alpha / AlphaSubtarget.cpp
1 //===- AlphaSubtarget.cpp - Alpha Subtarget Information ---------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by Andrew Lenharth and is distributed under the
6 // University of Illinois Open Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the Alpha specific subclass of TargetSubtarget.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "AlphaSubtarget.h"
15 #include "Alpha.h"
16 #include "llvm/Module.h"
17 #include "llvm/Support/CommandLine.h"
18 #include "llvm/Target/SubtargetFeature.h"
19 #include "llvm/Support/Debug.h"
20
21 using namespace llvm;
22
23 enum AlphaFeature {
24   AlphaFeatureCIX   = 1 << 0,
25   AlphaFeatureFIX = 1 << 1,
26 };
27
28 /// Sorted (by key) array of values for CPU subtype.
29 static const SubtargetFeatureKV AlphaSubTypeKV[] = {
30   { "ev56"    , "Select the Alpha EV56 processor", 0 },
31   { "ev6"    , "Select the Alpha EV6 processor", AlphaFeatureFIX },
32   { "ev67"    , "Select the Alpha EV67 processor", AlphaFeatureFIX | AlphaFeatureCIX },
33   { "generic", "Select instructions for a generic Alpha processor (EV56)", 0 },
34   { "pca56"    , "Select the Alpha PCA56 processor", 0 },
35 };
36
37 /// Length of AlphaSubTypeKV.
38 static const unsigned AlphaSubTypeKVSize = sizeof(AlphaSubTypeKV)
39                                              / sizeof(SubtargetFeatureKV);
40
41 /// Sorted (by key) array of values for CPU features.
42 static SubtargetFeatureKV AlphaFeatureKV[] = {
43   { "CIX", "Should CIX extentions be used" , AlphaFeatureCIX },
44   { "FIX"  , "Should FIX extentions be used"  , AlphaFeatureFIX },
45  };
46 /// Length of AlphaFeatureKV.
47 static const unsigned AlphaFeatureKVSize = sizeof(AlphaFeatureKV)
48                                           / sizeof(SubtargetFeatureKV);
49
50 AlphaSubtarget::AlphaSubtarget(const Module &M, const std::string &FS)
51   :HasF2I(false), HasCT(false)
52 {
53   std::string CPU = "generic";
54   uint32_t Bits =
55   SubtargetFeatures::Parse(FS, CPU,
56                            AlphaSubTypeKV, AlphaSubTypeKVSize,
57                            AlphaFeatureKV, AlphaFeatureKVSize);
58   HasF2I = (Bits & AlphaFeatureFIX) != 0;
59   HasCT  = (Bits & AlphaFeatureCIX) != 0;
60
61 }