blob: 794ecb304ac84a86ede9b89fdb442154bf7205e5 [file] [log] [blame]
Andrew Lenharth120ab482005-09-29 22:54:56 +00001//===- 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"
Andrew Lenharthac35cd22005-09-30 20:24:38 +000019#include "llvm/Support/Debug.h"
Andrew Lenharth120ab482005-09-29 22:54:56 +000020
21using namespace llvm;
22
Andrew Lenharthac35cd22005-09-30 20:24:38 +000023enum AlphaFeature {
24 AlphaFeatureCIX = 1 << 0,
25 AlphaFeatureFIX = 1 << 1,
26};
27
28/// Sorted (by key) array of values for CPU subtype.
29static 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 { "pca56" , "Select the Alpha PCA56 processor", 0 },
34 { "generic", "Select instructions for a generic Alpha processor (EV56)", 0 }
35};
36
37/// Length of AlphaSubTypeKV.
38static const unsigned AlphaSubTypeKVSize = sizeof(AlphaSubTypeKV)
39 / sizeof(SubtargetFeatureKV);
40
41/// Sorted (by key) array of values for CPU features.
42static SubtargetFeatureKV AlphaFeatureKV[] = {
43 { "FIX" , "Should FIX extentions be used" , AlphaFeatureFIX },
44 { "CIX", "Should CIX extentions be used" , AlphaFeatureCIX }
45 };
46/// Length of AlphaFeatureKV.
47static const unsigned AlphaFeatureKVSize = sizeof(AlphaFeatureKV)
48 / sizeof(SubtargetFeatureKV);
Andrew Lenharth120ab482005-09-29 22:54:56 +000049
50AlphaSubtarget::AlphaSubtarget(const Module &M, const std::string &FS)
51 :HasF2I(false), HasCT(false)
52{
Andrew Lenharthac35cd22005-09-30 20:24:38 +000053 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
Andrew Lenharth120ab482005-09-29 22:54:56 +000061}