Andrew Lenharth | 120ab48 | 2005-09-29 22:54:56 +0000 | [diff] [blame] | 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" |
Andrew Lenharth | ac35cd2 | 2005-09-30 20:24:38 +0000 | [diff] [blame^] | 19 | #include "llvm/Support/Debug.h" |
Andrew Lenharth | 120ab48 | 2005-09-29 22:54:56 +0000 | [diff] [blame] | 20 | |
| 21 | using namespace llvm; |
| 22 | |
Andrew Lenharth | ac35cd2 | 2005-09-30 20:24:38 +0000 | [diff] [blame^] | 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 | { "pca56" , "Select the Alpha PCA56 processor", 0 }, |
| 34 | { "generic", "Select instructions for a generic Alpha processor (EV56)", 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 | { "FIX" , "Should FIX extentions be used" , AlphaFeatureFIX }, |
| 44 | { "CIX", "Should CIX extentions be used" , AlphaFeatureCIX } |
| 45 | }; |
| 46 | /// Length of AlphaFeatureKV. |
| 47 | static const unsigned AlphaFeatureKVSize = sizeof(AlphaFeatureKV) |
| 48 | / sizeof(SubtargetFeatureKV); |
Andrew Lenharth | 120ab48 | 2005-09-29 22:54:56 +0000 | [diff] [blame] | 49 | |
| 50 | AlphaSubtarget::AlphaSubtarget(const Module &M, const std::string &FS) |
| 51 | :HasF2I(false), HasCT(false) |
| 52 | { |
Andrew Lenharth | ac35cd2 | 2005-09-30 20:24:38 +0000 | [diff] [blame^] | 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 | |
Andrew Lenharth | 120ab48 | 2005-09-29 22:54:56 +0000 | [diff] [blame] | 61 | } |