Home | History | Annotate | Download | only in R600
      1 //===-- AMDGPUSubtarget.cpp - AMDGPU Subtarget Information ----------------===//
      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 /// \file
     11 /// \brief Implements the AMDGPU specific subclass of TargetSubtarget.
     12 //
     13 //===----------------------------------------------------------------------===//
     14 
     15 #include "AMDGPUSubtarget.h"
     16 #include <stdio.h>
     17 
     18 using namespace llvm;
     19 
     20 #define GET_SUBTARGETINFO_ENUM
     21 #define GET_SUBTARGETINFO_TARGET_DESC
     22 #define GET_SUBTARGETINFO_CTOR
     23 #include "AMDGPUGenSubtargetInfo.inc"
     24 
     25 AMDGPUSubtarget::AMDGPUSubtarget(StringRef TT, StringRef CPU, StringRef FS) :
     26   AMDGPUGenSubtargetInfo(TT, CPU, FS), DumpCode(false) {
     27     InstrItins = getInstrItineraryForCPU(CPU);
     28 
     29   // Default card
     30   StringRef GPU = CPU;
     31   Is64bit = false;
     32   DefaultSize[0] = 64;
     33   DefaultSize[1] = 1;
     34   DefaultSize[2] = 1;
     35   HasVertexCache = false;
     36   TexVTXClauseSize = 0;
     37   Gen = AMDGPUSubtarget::R600;
     38   FP64 = false;
     39   CaymanISA = false;
     40   ParseSubtargetFeatures(GPU, FS);
     41   DevName = GPU;
     42 }
     43 
     44 bool
     45 AMDGPUSubtarget::is64bit() const  {
     46   return Is64bit;
     47 }
     48 bool
     49 AMDGPUSubtarget::hasVertexCache() const {
     50   return HasVertexCache;
     51 }
     52 short
     53 AMDGPUSubtarget::getTexVTXClauseSize() const {
     54   return TexVTXClauseSize;
     55 }
     56 enum AMDGPUSubtarget::Generation
     57 AMDGPUSubtarget::getGeneration() const {
     58   return Gen;
     59 }
     60 bool
     61 AMDGPUSubtarget::hasHWFP64() const {
     62   return FP64;
     63 }
     64 bool
     65 AMDGPUSubtarget::hasCaymanISA() const {
     66   return CaymanISA;
     67 }
     68 bool
     69 AMDGPUSubtarget::isTargetELF() const {
     70   return false;
     71 }
     72 size_t
     73 AMDGPUSubtarget::getDefaultSize(uint32_t dim) const {
     74   if (dim > 3) {
     75     return 1;
     76   } else {
     77     return DefaultSize[dim];
     78   }
     79 }
     80 
     81 std::string
     82 AMDGPUSubtarget::getDataLayout() const {
     83   std::string DataLayout = std::string(
     84    "e"
     85    "-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32"
     86    "-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128"
     87    "-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024-v2048:2048:2048"
     88    "-n32:64"
     89   );
     90 
     91   if (hasHWFP64()) {
     92     DataLayout.append("-f64:64:64");
     93   }
     94 
     95   if (is64bit()) {
     96     DataLayout.append("-p:64:64:64");
     97   } else {
     98     DataLayout.append("-p:32:32:32");
     99   }
    100 
    101   return DataLayout;
    102 }
    103 
    104 std::string
    105 AMDGPUSubtarget::getDeviceName() const {
    106   return DevName;
    107 }
    108