radeon/llvm: Move lowering of SETCC node to R600ISelLowering
[mesa.git] / src / gallium / drivers / radeon / radeon_llvm.h
index 9be7f90c3e6cd95756d32251e14fe3a651b5422b..7a32bb083b26ab212fe33ac7f035df897d1ac454 100644 (file)
@@ -36,6 +36,8 @@
 #define RADEON_LLVM_MAX_BRANCH_DEPTH 16
 #define RADEON_LLVM_MAX_LOOP_DEPTH 16
 
+#define RADEON_LLVM_MAX_SYSTEM_VALUES 4
+
 struct radeon_llvm_branch {
        LLVMBasicBlockRef endif_block;
        LLVMBasicBlockRef if_block;
@@ -78,6 +80,9 @@ struct radeon_llvm_context {
                        unsigned input_index,
                        const struct tgsi_full_declaration *decl);
 
+       void (*load_system_value)(struct radeon_llvm_context *,
+                       unsigned index,
+                       const struct tgsi_full_declaration *decl);
 
        /** User data to use with the callbacks */
        void * userdata;
@@ -90,6 +95,8 @@ struct radeon_llvm_context {
        LLVMValueRef outputs[RADEON_LLVM_MAX_OUTPUTS][TGSI_NUM_CHANNELS];
        unsigned output_reg_count;
 
+       LLVMValueRef system_values[RADEON_LLVM_MAX_SYSTEM_VALUES];
+
        unsigned reserved_reg_count;
        /*=== Private Members ===*/
 
@@ -105,6 +112,37 @@ struct radeon_llvm_context {
        struct gallivm_state gallivm;
 };
 
+static inline LLVMValueRef bitcast(
+               struct lp_build_tgsi_context * bld_base,
+               enum tgsi_opcode_type type,
+               LLVMValueRef value
+)
+{
+       LLVMBuilderRef builder = bld_base->base.gallivm->builder;
+       LLVMContextRef ctx = bld_base->base.gallivm->context;
+       LLVMTypeRef dst_type;
+
+       switch (type) {
+       case TGSI_TYPE_UNSIGNED:
+       case TGSI_TYPE_SIGNED:
+               dst_type = LLVMInt32TypeInContext(ctx);
+               break;
+       case TGSI_TYPE_UNTYPED:
+       case TGSI_TYPE_FLOAT:
+               dst_type = LLVMFloatTypeInContext(ctx);
+               break;
+       default:
+               dst_type = 0;
+               break;
+       }
+
+       if (dst_type)
+               return LLVMBuildBitCast(builder, value, dst_type, "");
+       else
+               return value;
+}
+
+
 void radeon_llvm_context_init(struct radeon_llvm_context * ctx);
 
 void radeon_llvm_dispose(struct radeon_llvm_context * ctx);
@@ -119,4 +157,20 @@ unsigned radeon_llvm_reg_index_soa(unsigned index, unsigned chan);
 
 void radeon_llvm_finalize_module(struct radeon_llvm_context * ctx);
 
+LLVMValueRef
+build_intrinsic(LLVMBuilderRef builder,
+               const char *name,
+               LLVMTypeRef ret_type,
+               LLVMValueRef *args,
+               unsigned num_args,
+               LLVMAttribute attr);
+
+void
+build_tgsi_intrinsic_nomem(
+               const struct lp_build_tgsi_action * action,
+               struct lp_build_tgsi_context * bld_base,
+               struct lp_build_emit_data * emit_data);
+
+
+
 #endif /* RADEON_LLVM_H */