1 //===-- TargetParser - Parser for target features ---------------*- 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 implements a target parser to recognise hardware features such as 11 // FPU/CPU/ARCH names as well as specific support such as HDIV, etc. 12 // 13 //===----------------------------------------------------------------------===// 14 15 #ifndef LLVM_SUPPORT_TARGETPARSER_H 16 #define LLVM_SUPPORT_TARGETPARSER_H 17 18 // FIXME: vector is used because that's what clang uses for subtarget feature 19 // lists, but SmallVector would probably be better 20 #include "llvm/ADT/Triple.h" 21 #include "llvm/Support/ARMTargetParser.h" 22 #include "llvm/Support/AArch64TargetParser.h" 23 #include <vector> 24 25 namespace llvm { 26 class StringRef; 27 28 // Target specific information in their own namespaces. 29 // (ARM/AArch64 are declared in ARM/AArch64TargetParser.h) 30 // These should be generated from TableGen because the information is already 31 // there, and there is where new information about targets will be added. 32 // FIXME: To TableGen this we need to make some table generated files available 33 // even if the back-end is not compiled with LLVM, plus we need to create a new 34 // back-end to TableGen to create these clean tables. 35 namespace X86 { 36 37 // This should be kept in sync with libcc/compiler-rt as its included by clang 38 // as a proxy for what's in libgcc/compiler-rt. 39 enum ProcessorVendors : unsigned { 40 VENDOR_DUMMY, 41 #define X86_VENDOR(ENUM, STRING) \ 42 ENUM, 43 #include "llvm/Support/X86TargetParser.def" 44 VENDOR_OTHER 45 }; 46 47 // This should be kept in sync with libcc/compiler-rt as its included by clang 48 // as a proxy for what's in libgcc/compiler-rt. 49 enum ProcessorTypes : unsigned { 50 CPU_TYPE_DUMMY, 51 #define X86_CPU_TYPE(ARCHNAME, ENUM) \ 52 ENUM, 53 #include "llvm/Support/X86TargetParser.def" 54 CPU_TYPE_MAX 55 }; 56 57 // This should be kept in sync with libcc/compiler-rt as its included by clang 58 // as a proxy for what's in libgcc/compiler-rt. 59 enum ProcessorSubtypes : unsigned { 60 CPU_SUBTYPE_DUMMY, 61 #define X86_CPU_SUBTYPE(ARCHNAME, ENUM) \ 62 ENUM, 63 #include "llvm/Support/X86TargetParser.def" 64 CPU_SUBTYPE_MAX 65 }; 66 67 // This should be kept in sync with libcc/compiler-rt as it should be used 68 // by clang as a proxy for what's in libgcc/compiler-rt. 69 enum ProcessorFeatures { 70 #define X86_FEATURE(VAL, ENUM) \ 71 ENUM = VAL, 72 #include "llvm/Support/X86TargetParser.def" 73 74 }; 75 76 } // namespace X86 77 78 namespace AMDGPU { 79 80 /// GPU kinds supported by the AMDGPU target. 81 enum GPUKind : uint32_t { 82 // Not specified processor. 83 GK_NONE = 0, 84 85 // R600-based processors. 86 GK_R600 = 1, 87 GK_R630 = 2, 88 GK_RS880 = 3, 89 GK_RV670 = 4, 90 GK_RV710 = 5, 91 GK_RV730 = 6, 92 GK_RV770 = 7, 93 GK_CEDAR = 8, 94 GK_CYPRESS = 9, 95 GK_JUNIPER = 10, 96 GK_REDWOOD = 11, 97 GK_SUMO = 12, 98 GK_BARTS = 13, 99 GK_CAICOS = 14, 100 GK_CAYMAN = 15, 101 GK_TURKS = 16, 102 103 GK_R600_FIRST = GK_R600, 104 GK_R600_LAST = GK_TURKS, 105 106 // AMDGCN-based processors. 107 GK_GFX600 = 32, 108 GK_GFX601 = 33, 109 110 GK_GFX700 = 40, 111 GK_GFX701 = 41, 112 GK_GFX702 = 42, 113 GK_GFX703 = 43, 114 GK_GFX704 = 44, 115 116 GK_GFX801 = 50, 117 GK_GFX802 = 51, 118 GK_GFX803 = 52, 119 GK_GFX810 = 53, 120 121 GK_GFX900 = 60, 122 GK_GFX902 = 61, 123 GK_GFX904 = 62, 124 GK_GFX906 = 63, 125 GK_GFX909 = 65, 126 127 GK_AMDGCN_FIRST = GK_GFX600, 128 GK_AMDGCN_LAST = GK_GFX909, 129 }; 130 131 /// Instruction set architecture version. 132 struct IsaVersion { 133 unsigned Major; 134 unsigned Minor; 135 unsigned Stepping; 136 }; 137 138 // This isn't comprehensive for now, just things that are needed from the 139 // frontend driver. 140 enum ArchFeatureKind : uint32_t { 141 FEATURE_NONE = 0, 142 143 // These features only exist for r600, and are implied true for amdgcn. 144 FEATURE_FMA = 1 << 1, 145 FEATURE_LDEXP = 1 << 2, 146 FEATURE_FP64 = 1 << 3, 147 148 // Common features. 149 FEATURE_FAST_FMA_F32 = 1 << 4, 150 FEATURE_FAST_DENORMAL_F32 = 1 << 5 151 }; 152 153 StringRef getArchNameAMDGCN(GPUKind AK); 154 StringRef getArchNameR600(GPUKind AK); 155 StringRef getCanonicalArchName(StringRef Arch); 156 GPUKind parseArchAMDGCN(StringRef CPU); 157 GPUKind parseArchR600(StringRef CPU); 158 unsigned getArchAttrAMDGCN(GPUKind AK); 159 unsigned getArchAttrR600(GPUKind AK); 160 161 void fillValidArchListAMDGCN(SmallVectorImpl<StringRef> &Values); 162 void fillValidArchListR600(SmallVectorImpl<StringRef> &Values); 163 164 IsaVersion getIsaVersion(StringRef GPU); 165 166 } // namespace AMDGPU 167 168 } // namespace llvm 169 170 #endif 171