[PATCH] R600: Define device name macros.

Tom Stellard tom at stellard.net
Tue Jul 15 07:58:48 PDT 2014


On Tue, Jul 15, 2014 at 02:32:20AM +0000, Matt Arsenault wrote:
> These should be compatible with the ones the AMD OpenCL compiler defines.
> 
> http://reviews.llvm.org/D4507
> 
> Files:
>   lib/Basic/Targets.cpp

> Index: lib/Basic/Targets.cpp
> ===================================================================
> --- lib/Basic/Targets.cpp
> +++ lib/Basic/Targets.cpp
> @@ -1472,8 +1472,46 @@
>  class R600TargetInfo : public TargetInfo {
>    static const Builtin::Info BuiltinInfo[];
>  
> -  /// \brief The GPU profiles supported by the R600 target.
> +  /// \brief The specific GPU types supported by the R600 target.
>    enum GPUKind {
> +    GPU_NONE = 0,
> +    GPU_R600,
> +    GPU_RV610,
> +    GPU_RV620,
> +    GPU_RV630,
> +    GPU_RV635,
> +    GPU_RS780,
> +    GPU_RS880,
> +    GPU_RV670,
> +    GPU_RV710,
> +    GPU_RV730,
> +    GPU_RV740,
> +    GPU_RV770, // XXX - 790?
> +    GPU_PALM,
> +    GPU_CEDAR,
> +    GPU_SUMO,
> +    GPU_SUMO2,
> +    GPU_REDWOOD,
> +    GPU_JUNIPER,
> +    GPU_HEMLOCK,
> +    GPU_CYPRESS,
> +    GPU_BARTS,
> +    GPU_TURKS,
> +    GPU_CAICOS,
> +    GPU_CAYMAN,
> +    GPU_ARUBA,
> +    GPU_TAHITI,
> +    GPU_PITCAIRN,
> +    GPU_VERDE,
> +    GPU_OLAND,
> +    GPU_BONAIRE,
> +    GPU_KABINI,
> +    GPU_KAVERI,
> +    GPU_HAWAII
> +  } GPU;
> +
> +  /// \brief The GPU profiles supported by the R600 target.
> +  enum GPUGenerationKind {
>      GK_NONE,
>      GK_R600,
>      GK_R600_DOUBLE_OPS,
> @@ -1485,17 +1523,135 @@
>      GK_CAYMAN,
>      GK_SOUTHERN_ISLANDS,
>      GK_SEA_ISLANDS
> -  } GPU;
> +  } GPUGeneration;
> +
> +  static GPUGenerationKind getGenKind(GPUKind GPU) {
> +    switch (GPU) {
> +    case GPU_R600:
> +    case GPU_RV610:
> +    case GPU_RV620:
> +    case GPU_RV630:
> +    case GPU_RV635:
> +    case GPU_RS780:
> +    case GPU_RS880:
> +      return GK_R600;
> +    case GPU_RV670:
> +      return GK_R600_DOUBLE_OPS;
> +    case GPU_RV710:
> +    case GPU_RV730:
> +      return GK_R700;
> +    case GPU_RV740:
> +    case GPU_RV770:
> +      return GK_R700_DOUBLE_OPS;
> +    case GPU_PALM:
> +    case GPU_CEDAR:
> +    case GPU_SUMO:
> +    case GPU_SUMO2:
> +    case GPU_REDWOOD:
> +    case GPU_JUNIPER:
> +      return GK_EVERGREEN;
> +    case GPU_HEMLOCK:
> +    case GPU_CYPRESS:
> +      return GK_EVERGREEN_DOUBLE_OPS;
> +    case GPU_BARTS:
> +    case GPU_TURKS:
> +    case GPU_CAICOS:
> +      return GK_NORTHERN_ISLANDS;
> +    case GPU_CAYMAN:
> +    case GPU_ARUBA:
> +      return GK_CAYMAN;
> +    case GPU_TAHITI:
> +    case GPU_PITCAIRN:
> +    case GPU_VERDE:
> +    case GPU_OLAND:
> +      return GK_SOUTHERN_ISLANDS;
> +    case GPU_BONAIRE:
> +    case GPU_KABINI:
> +    case GPU_KAVERI:
> +    case GPU_HAWAII:
> +      return GK_SEA_ISLANDS;
> +    default:
> +      return GK_NONE;
> +    }
> +  }
> +
> +  // These are documented in the AMD OpenCL Programming guide for identifying
> +  // which device is targeted.
> +  static StringRef getAMDCompatDeviceMacro(GPUKind Kind) {
> +    switch (Kind) {
> +    case GPU_R600:
> +    case GPU_RV610:
> +    case GPU_RV620:
> +    case GPU_RV630:
> +    case GPU_RV635:
> +    case GPU_RS780:
> +    case GPU_RS880:
> +    case GPU_RV670:
> +      return "";
> +    case GPU_RV710:
> +      return "__ATI_RV710__";
> +    case GPU_RV730:
> +      return "__ATI_RV730__";
> +    case GPU_RV740:
> +      return "__ATI_RV740__";
> +    case GPU_RV770:
> +      return "__ATI_RV770__";
> +    case GPU_PALM:
> +      return "__Loveland__";
> +    case GPU_CEDAR:
> +      return "__Cedar__";
> +    case GPU_SUMO:
> +      return "__WinterPark__";
> +    case GPU_SUMO2:
> +      return "__BeaverCreek__";
> +    case GPU_REDWOOD:
> +      return "__Redwood__";
> +    case GPU_JUNIPER:
> +      return "__Juniper__";
> +    case GPU_HEMLOCK:
> +    case GPU_CYPRESS:
> +      return "__Cypress__";
> +    case GPU_BARTS:
> +      return "__Barts__";
> +    case GPU_TURKS:
> +      return "__Turks__";
> +    case GPU_CAICOS:
> +      return "__Caicos__";
> +    case GPU_CAYMAN:
> +      return "__Cayman__";
> +    case GPU_ARUBA:
> +      return ""; // ???

Aruba = Trinity which is the mobile version of Cayman, so I'm
guessing this should return __Cayman__

> +    case GPU_TAHITI:
> +      return "__Tahiti__";
> +    case GPU_PITCAIRN:
> +      return "__Pitcairn__";
> +    case GPU_VERDE:
> +      return "__Capeverde__";
> +    case GPU_OLAND:
> +      return "__Oland__";
> +    case GPU_BONAIRE:
> +      return "__Bonaire__";
> +    case GPU_KABINI:
> +    case GPU_KAVERI:
> +      return ""; // ???

These are probably Bonaire too.


> +    case GPU_HAWAII:
> +      return "__Hawaii__";
> +    default:
> +      return "";
> +    }
> +  }
>  
>  public:
>    R600TargetInfo(const llvm::Triple &Triple)
> -      : TargetInfo(Triple), GPU(GK_R600) {
> +      : TargetInfo(Triple),
> +        GPU(GPU_NONE),
> +        GPUGeneration(GK_NONE) {
>      DescriptionString = DescriptionStringR600;
>      AddrSpaceMap = &R600AddrSpaceMap;
>      UseAddrSpaceMapMangling = true;
>    }
>  
> -  const char * getClobbers() const override {
> +  const char *getClobbers() const override {
>      return "";
>    }
>  

> @@ -1525,6 +1681,14 @@
>    void getTargetDefines(const LangOptions &Opts,
>                          MacroBuilder &Builder) const override {
>      Builder.defineMacro("__R600__");
> +
> +    if (GPU != GPU_NONE) {
> +      Builder.defineMacro("__GPU__");
> +
> +      StringRef Macro = getAMDCompatDeviceMacro(GPU);
> +      if (!Macro.empty())
> +        Builder.defineMacro(Macro);
> +    }
>    }
>  
>    BuiltinVaListKind getBuiltinVaListKind() const override {
> @@ -1533,47 +1697,48 @@
>  
>    bool setCPU(const std::string &Name) override {
>      GPU = llvm::StringSwitch<GPUKind>(Name)
> -      .Case("r600" ,    GK_R600)
> -      .Case("rv610",    GK_R600)
> -      .Case("rv620",    GK_R600)
> -      .Case("rv630",    GK_R600)
> -      .Case("rv635",    GK_R600)
> -      .Case("rs780",    GK_R600)
> -      .Case("rs880",    GK_R600)
> -      .Case("rv670",    GK_R600_DOUBLE_OPS)
> -      .Case("rv710",    GK_R700)
> -      .Case("rv730",    GK_R700)
> -      .Case("rv740",    GK_R700_DOUBLE_OPS)
> -      .Case("rv770",    GK_R700_DOUBLE_OPS)
> -      .Case("palm",     GK_EVERGREEN)
> -      .Case("cedar",    GK_EVERGREEN)
> -      .Case("sumo",     GK_EVERGREEN)
> -      .Case("sumo2",    GK_EVERGREEN)
> -      .Case("redwood",  GK_EVERGREEN)
> -      .Case("juniper",  GK_EVERGREEN)
> -      .Case("hemlock",  GK_EVERGREEN_DOUBLE_OPS)
> -      .Case("cypress",  GK_EVERGREEN_DOUBLE_OPS)
> -      .Case("barts",    GK_NORTHERN_ISLANDS)
> -      .Case("turks",    GK_NORTHERN_ISLANDS)
> -      .Case("caicos",   GK_NORTHERN_ISLANDS)
> -      .Case("cayman",   GK_CAYMAN)
> -      .Case("aruba",    GK_CAYMAN)
> -      .Case("tahiti",   GK_SOUTHERN_ISLANDS)
> -      .Case("pitcairn", GK_SOUTHERN_ISLANDS)
> -      .Case("verde",    GK_SOUTHERN_ISLANDS)
> -      .Case("oland",    GK_SOUTHERN_ISLANDS)
> -      .Case("bonaire",  GK_SEA_ISLANDS)
> -      .Case("kabini",   GK_SEA_ISLANDS)
> -      .Case("kaveri",   GK_SEA_ISLANDS)
> -      .Case("hawaii",   GK_SEA_ISLANDS)
> -      .Default(GK_NONE);
> -
> -    if (GPU == GK_NONE) {
> +      .Case("r600",     GPU_R600)
> +      .Case("rv610",    GPU_RV610)
> +      .Case("rv620",    GPU_RV620)
> +      .Case("rv630",    GPU_RV630)
> +      .Case("rv635",    GPU_RV635)
> +      .Case("rs780",    GPU_RS780)
> +      .Case("rs880",    GPU_RS880)
> +      .Case("rv670",    GPU_RV670)
> +      .Case("rv710",    GPU_RV710)
> +      .Case("rv730",    GPU_RV730)
> +      .Case("rv740",    GPU_RV740)
> +      .Case("rv770",    GPU_RV770)
> +      .Case("palm",     GPU_PALM)
> +      .Case("cedar",    GPU_CEDAR)
> +      .Case("sumo",     GPU_SUMO)
> +      .Case("sumo2",    GPU_SUMO2)
> +      .Case("redwood",  GPU_REDWOOD)
> +      .Case("juniper",  GPU_JUNIPER)
> +      .Case("hemlock",  GPU_HEMLOCK)
> +      .Case("cypress",  GPU_CYPRESS)
> +      .Case("barts",    GPU_BARTS)
> +      .Case("turks",    GPU_TURKS)
> +      .Case("caicos",   GPU_CAICOS)
> +      .Case("cayman",   GPU_CAYMAN)
> +      .Case("aruba",    GPU_ARUBA)
> +      .Case("tahiti",   GPU_TAHITI)
> +      .Case("pitcairn", GPU_PITCAIRN)
> +      .Case("verde",    GPU_VERDE)
> +      .Case("oland",    GPU_OLAND)
> +      .Case("bonaire",  GPU_BONAIRE)
> +      .Case("kabini",   GPU_KABINI)
> +      .Case("kaveri",   GPU_KAVERI)
> +      .Case("hawaii",   GPU_HAWAII)
> +      .Default(GPU_NONE);
> +
> +    if (GPU == GPU_NONE)
>        return false;
> -    }
>  
> -    // Set the correct data layout
> -    switch (GPU) {
> +    GPUGeneration = getGenKind(GPU);
> +
> +    // Set the correct data layout.
> +    switch (GPUGeneration) {
>      case GK_NONE:
>      case GK_R600:
>      case GK_R700:

> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list