clover: Add a function for retrieving a device's preferred ir v3
authorTom Stellard <thomas.stellard@amd.com>
Mon, 23 Apr 2012 16:09:08 +0000 (12:09 -0400)
committerTom Stellard <thomas.stellard@amd.com>
Fri, 1 Jun 2012 15:28:09 +0000 (11:28 -0400)
A device now has two function for getting information about the IR
it needs to return.

ir_format() => returns the preferred IR
ir_target() => returns the triple for the target that is understood by
                 clang/llvm.

v2:
  - renamed ir_target() to ir_format()
  - renamed llvm_triple() to ir_target()

v3:
  - Remove unnecessary include
  - Do proper conversion from std::vector<char> to std::string

Reviewed-by: Francisco Jerez <currojerez@riseup.net>
src/gallium/state_trackers/clover/core/device.cpp
src/gallium/state_trackers/clover/core/device.hpp

index 69b1b4a6ac01d16a3ee3edc9c313d116dedc0302..2ab735d9a2a82d75ea4b07c3141f67b3b9bcadea 100644 (file)
@@ -160,16 +160,18 @@ _cl_device_id::vendor_name() const {
    return pipe->get_vendor(pipe);
 }
 
+enum pipe_shader_ir
+_cl_device_id::ir_format() const {
+   return (enum pipe_shader_ir) pipe->get_shader_param(pipe,
+                                                  PIPE_SHADER_COMPUTE,
+                                                  PIPE_SHADER_CAP_PREFERRED_IR);
+}
+
 std::string
 _cl_device_id::ir_target() const {
-   switch (pipe->get_shader_param(pipe, PIPE_SHADER_COMPUTE,
-                                  PIPE_SHADER_CAP_PREFERRED_IR)) {
-   case PIPE_SHADER_IR_TGSI:
-      return "tgsi";
-   default:
-      assert(0);
-      return "";
-   }
+   std::vector<char> target = get_compute_param<char>(pipe,
+                                                    PIPE_COMPUTE_CAP_IR_TARGET);
+   return { target.data() };
 }
 
 device_registry::device_registry() {
index d10635275b1d12917adad89971d8bd422fde0b27..9408083e47948c350bc9d29feab69bf5ec79b36b 100644 (file)
@@ -60,6 +60,7 @@ public:
    std::vector<size_t> max_block_size() const;
    std::string device_name() const;
    std::string vendor_name() const;
+   enum pipe_shader_ir ir_format() const;
    std::string ir_target() const;
 
    friend struct _cl_command_queue;