Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 393013
Collapse All | Expand All

(-)a/src/gallium/auxiliary/draw/draw_llvm.c (-13 / +35 lines)
Lines 96-102 draw_llvm_generate_elts(struct draw_llvm *llvm, struct draw_llvm_variant *var); Link Here
96
 * Create LLVM type for struct draw_jit_texture
96
 * Create LLVM type for struct draw_jit_texture
97
 */
97
 */
98
static LLVMTypeRef
98
static LLVMTypeRef
99
create_jit_texture_type(struct gallivm_state *gallivm)
99
create_jit_texture_type(struct gallivm_state *gallivm, const char *struct_name)
100
{
100
{
101
   LLVMTargetDataRef target = gallivm->target;
101
   LLVMTargetDataRef target = gallivm->target;
102
   LLVMTypeRef texture_type;
102
   LLVMTypeRef texture_type;
Lines 120-132 create_jit_texture_type(struct gallivm_state *gallivm) Link Here
120
   elem_types[DRAW_JIT_TEXTURE_BORDER_COLOR] = 
120
   elem_types[DRAW_JIT_TEXTURE_BORDER_COLOR] = 
121
      LLVMArrayType(LLVMFloatTypeInContext(gallivm->context), 4);
121
      LLVMArrayType(LLVMFloatTypeInContext(gallivm->context), 4);
122
122
123
#if HAVE_LLVM >= 0x0300
124
   texture_type = LLVMStructCreateNamed(gallivm->context, struct_name);
125
   LLVMStructSetBody(texture_type, elem_types,
126
                     Elements(elem_types), 0);
127
#else
123
   texture_type = LLVMStructTypeInContext(gallivm->context, elem_types,
128
   texture_type = LLVMStructTypeInContext(gallivm->context, elem_types,
124
                                          Elements(elem_types), 0);
129
                                          Elements(elem_types), 0);
125
130
131
   LLVMAddTypeName(gallivm->module, struct_name, texture_type);
132
126
   /* Make sure the target's struct layout cache doesn't return
133
   /* Make sure the target's struct layout cache doesn't return
127
    * stale/invalid data.
134
    * stale/invalid data.
128
    */
135
    */
129
   LLVMInvalidateStructLayout(gallivm->target, texture_type);
136
   LLVMInvalidateStructLayout(gallivm->target, texture_type);
137
#endif
130
138
131
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, width,
139
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, width,
132
                          target, texture_type,
140
                          target, texture_type,
Lines 176-182 create_jit_texture_type(struct gallivm_state *gallivm) Link Here
176
 */
184
 */
177
static LLVMTypeRef
185
static LLVMTypeRef
178
create_jit_context_type(struct gallivm_state *gallivm,
186
create_jit_context_type(struct gallivm_state *gallivm,
179
                        LLVMTypeRef texture_type)
187
                        LLVMTypeRef texture_type, const char *struct_name)
180
{
188
{
181
   LLVMTargetDataRef target = gallivm->target;
189
   LLVMTargetDataRef target = gallivm->target;
182
   LLVMTypeRef float_type = LLVMFloatTypeInContext(gallivm->context);
190
   LLVMTypeRef float_type = LLVMFloatTypeInContext(gallivm->context);
Lines 189-199 create_jit_context_type(struct gallivm_state *gallivm, Link Here
189
   elem_types[3] = LLVMPointerType(float_type, 0); /* viewport */
197
   elem_types[3] = LLVMPointerType(float_type, 0); /* viewport */
190
   elem_types[4] = LLVMArrayType(texture_type,
198
   elem_types[4] = LLVMArrayType(texture_type,
191
                                 PIPE_MAX_VERTEX_SAMPLERS); /* textures */
199
                                 PIPE_MAX_VERTEX_SAMPLERS); /* textures */
192
200
#if HAVE_LLVM >= 0x0300
201
   context_type = LLVMStructCreateNamed(gallivm->context, struct_name);
202
   LLVMStructSetBody(context_type, elem_types,
203
                     Elements(elem_types), 0);
204
#else
193
   context_type = LLVMStructTypeInContext(gallivm->context, elem_types,
205
   context_type = LLVMStructTypeInContext(gallivm->context, elem_types,
194
                                          Elements(elem_types), 0);
206
                                          Elements(elem_types), 0);
207
   LLVMAddTypeName(gallivm->module, struct_name, context_type);
195
208
196
   LLVMInvalidateStructLayout(gallivm->target, context_type);
209
   LLVMInvalidateStructLayout(gallivm->target, context_type);
210
#endif
197
211
198
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, vs_constants,
212
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, vs_constants,
199
                          target, context_type, 0);
213
                          target, context_type, 0);
Lines 215-221 create_jit_context_type(struct gallivm_state *gallivm, Link Here
215
 * Create LLVM type for struct pipe_vertex_buffer
229
 * Create LLVM type for struct pipe_vertex_buffer
216
 */
230
 */
217
static LLVMTypeRef
231
static LLVMTypeRef
218
create_jit_vertex_buffer_type(struct gallivm_state *gallivm)
232
create_jit_vertex_buffer_type(struct gallivm_state *gallivm, const char *struct_name)
219
{
233
{
220
   LLVMTargetDataRef target = gallivm->target;
234
   LLVMTargetDataRef target = gallivm->target;
221
   LLVMTypeRef elem_types[3];
235
   LLVMTypeRef elem_types[3];
Lines 225-234 create_jit_vertex_buffer_type(struct gallivm_state *gallivm) Link Here
225
   elem_types[1] = LLVMInt32TypeInContext(gallivm->context);
239
   elem_types[1] = LLVMInt32TypeInContext(gallivm->context);
226
   elem_types[2] = LLVMPointerType(LLVMInt8TypeInContext(gallivm->context), 0); /* vs_constants */
240
   elem_types[2] = LLVMPointerType(LLVMInt8TypeInContext(gallivm->context), 0); /* vs_constants */
227
241
242
#if HAVE_LLVM >= 0x0300
243
   vb_type = LLVMStructCreateNamed(gallivm->context, struct_name);
244
   LLVMStructSetBody(vb_type, elem_types,
245
                     Elements(elem_types), 0);
246
#else
228
   vb_type = LLVMStructTypeInContext(gallivm->context, elem_types,
247
   vb_type = LLVMStructTypeInContext(gallivm->context, elem_types,
229
                                     Elements(elem_types), 0);
248
                                     Elements(elem_types), 0);
249
   LLVMAddTypeName(gallivm->module, struct_name, vb_type);
230
250
231
   LLVMInvalidateStructLayout(gallivm->target, vb_type);
251
   LLVMInvalidateStructLayout(gallivm->target, vb_type);
252
#endif
232
253
233
   LP_CHECK_MEMBER_OFFSET(struct pipe_vertex_buffer, stride,
254
   LP_CHECK_MEMBER_OFFSET(struct pipe_vertex_buffer, stride,
234
                          target, vb_type, 0);
255
                          target, vb_type, 0);
Lines 258-267 create_jit_vertex_header(struct gallivm_state *gallivm, int data_elems) Link Here
258
   elem_types[1]  = LLVMArrayType(LLVMFloatTypeInContext(gallivm->context), 4);
279
   elem_types[1]  = LLVMArrayType(LLVMFloatTypeInContext(gallivm->context), 4);
259
   elem_types[2]  = LLVMArrayType(elem_types[1], data_elems);
280
   elem_types[2]  = LLVMArrayType(elem_types[1], data_elems);
260
281
282
#if HAVE_LLVM >= 0x0300
283
   vertex_header = LLVMStructCreateNamed(gallivm->context, struct_name);
284
   LLVMStructSetBody(vertex_header, elem_types,
285
                     Elements(elem_types), 0);
286
#else
261
   vertex_header = LLVMStructTypeInContext(gallivm->context, elem_types,
287
   vertex_header = LLVMStructTypeInContext(gallivm->context, elem_types,
262
                                           Elements(elem_types), 0);
288
                                           Elements(elem_types), 0);
289
   LLVMAddTypeName(gallivm->module, struct_name, vertex_header);
263
290
264
   LLVMInvalidateStructLayout(gallivm->target, vertex_header);
291
   LLVMInvalidateStructLayout(gallivm->target, vertex_header);
292
#endif
265
293
266
   /* these are bit-fields and we can't take address of them
294
   /* these are bit-fields and we can't take address of them
267
      LP_CHECK_MEMBER_OFFSET(struct vertex_header, clipmask,
295
      LP_CHECK_MEMBER_OFFSET(struct vertex_header, clipmask,
Lines 284-291 create_jit_vertex_header(struct gallivm_state *gallivm, int data_elems) Link Here
284
                          target, vertex_header,
312
                          target, vertex_header,
285
                          DRAW_JIT_VERTEX_DATA);
313
                          DRAW_JIT_VERTEX_DATA);
286
314
287
   LLVMAddTypeName(gallivm->module, struct_name, vertex_header);
288
289
   return vertex_header;
315
   return vertex_header;
290
}
316
}
291
317
Lines 299-317 create_jit_types(struct draw_llvm *llvm) Link Here
299
   struct gallivm_state *gallivm = llvm->gallivm;
325
   struct gallivm_state *gallivm = llvm->gallivm;
300
   LLVMTypeRef texture_type, context_type, buffer_type, vb_type;
326
   LLVMTypeRef texture_type, context_type, buffer_type, vb_type;
301
327
302
   texture_type = create_jit_texture_type(gallivm);
328
   texture_type = create_jit_texture_type(gallivm, "texture");
303
   LLVMAddTypeName(gallivm->module, "texture", texture_type);
304
329
305
   context_type = create_jit_context_type(gallivm, texture_type);
330
   context_type = create_jit_context_type(gallivm, texture_type, "draw_jit_context");
306
   LLVMAddTypeName(gallivm->module, "draw_jit_context", context_type);
307
   llvm->context_ptr_type = LLVMPointerType(context_type, 0);
331
   llvm->context_ptr_type = LLVMPointerType(context_type, 0);
308
332
309
   buffer_type = LLVMPointerType(LLVMIntTypeInContext(gallivm->context, 8), 0);
333
   buffer_type = LLVMPointerType(LLVMIntTypeInContext(gallivm->context, 8), 0);
310
   LLVMAddTypeName(gallivm->module, "buffer", buffer_type);
311
   llvm->buffer_ptr_type = LLVMPointerType(buffer_type, 0);
334
   llvm->buffer_ptr_type = LLVMPointerType(buffer_type, 0);
312
335
313
   vb_type = create_jit_vertex_buffer_type(gallivm);
336
   vb_type = create_jit_vertex_buffer_type(gallivm, "pipe_vertex_buffer");
314
   LLVMAddTypeName(gallivm->module, "pipe_vertex_buffer", vb_type);
315
   llvm->vb_ptr_type = LLVMPointerType(vb_type, 0);
337
   llvm->vb_ptr_type = LLVMPointerType(vb_type, 0);
316
}
338
}
317
339
(-)a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp (-7 / +36 lines)
Lines 27-43 Link Here
27
27
28
#include <llvm-c/Core.h>
28
#include <llvm-c/Core.h>
29
#include <llvm/Target/TargetMachine.h>
29
#include <llvm/Target/TargetMachine.h>
30
#include <llvm/Target/TargetRegistry.h>
31
#include <llvm/Target/TargetSelect.h>
32
#include <llvm/Target/TargetInstrInfo.h>
30
#include <llvm/Target/TargetInstrInfo.h>
33
#include <llvm/Support/raw_ostream.h>
31
#include <llvm/Support/raw_ostream.h>
34
#include <llvm/Support/MemoryObject.h>
32
#include <llvm/Support/MemoryObject.h>
35
33
34
#if HAVE_LLVM >= 0x0300
35
#include <llvm/Support/TargetRegistry.h>
36
#include <llvm/Support/TargetSelect.h>
37
#else /* HAVE_LLVM < 0x0300 */
38
#include <llvm/Target/TargetRegistry.h>
39
#include <llvm/Target/TargetSelect.h>
40
#endif /* HAVE_LLVM < 0x0300 */
41
36
#if HAVE_LLVM >= 0x0209
42
#if HAVE_LLVM >= 0x0209
37
#include <llvm/Support/Host.h>
43
#include <llvm/Support/Host.h>
38
#else
44
#else /* HAVE_LLVM < 0x0209 */
39
#include <llvm/System/Host.h>
45
#include <llvm/System/Host.h>
40
#endif
46
#endif /* HAVE_LLVM < 0x0209 */
41
47
42
#if HAVE_LLVM >= 0x0207
48
#if HAVE_LLVM >= 0x0207
43
#include <llvm/MC/MCDisassembler.h>
49
#include <llvm/MC/MCDisassembler.h>
Lines 193-206 lp_disassemble(const void* func) Link Here
193
199
194
   InitializeAllDisassemblers();
200
   InitializeAllDisassemblers();
195
201
202
#if HAVE_LLVM >= 0x0300
203
   OwningPtr<const MCAsmInfo> AsmInfo(T->createMCAsmInfo(Triple));
204
#else
196
   OwningPtr<const MCAsmInfo> AsmInfo(T->createAsmInfo(Triple));
205
   OwningPtr<const MCAsmInfo> AsmInfo(T->createAsmInfo(Triple));
206
#endif
197
207
198
   if (!AsmInfo) {
208
   if (!AsmInfo) {
199
      debug_printf("error: no assembly info for target %s\n", Triple.c_str());
209
      debug_printf("error: no assembly info for target %s\n", Triple.c_str());
200
      return;
210
      return;
201
   }
211
   }
202
212
213
#if HAVE_LLVM >= 0x0300
214
   const MCSubtargetInfo *STI = T->createMCSubtargetInfo(Triple, sys::getHostCPUName(), "");
215
   OwningPtr<const MCDisassembler> DisAsm(T->createMCDisassembler(*STI));
216
#else 
203
   OwningPtr<const MCDisassembler> DisAsm(T->createMCDisassembler());
217
   OwningPtr<const MCDisassembler> DisAsm(T->createMCDisassembler());
218
#endif 
204
   if (!DisAsm) {
219
   if (!DisAsm) {
205
      debug_printf("error: no disassembler for target %s\n", Triple.c_str());
220
      debug_printf("error: no disassembler for target %s\n", Triple.c_str());
206
      return;
221
      return;
Lines 213-219 lp_disassemble(const void* func) Link Here
213
#else
228
#else
214
   int AsmPrinterVariant = AsmInfo->getAssemblerDialect();
229
   int AsmPrinterVariant = AsmInfo->getAssemblerDialect();
215
#endif
230
#endif
216
#if HAVE_LLVM >= 0x0208
231
232
#if HAVE_LLVM >= 0x0300
233
   OwningPtr<MCInstPrinter> Printer(
234
         T->createMCInstPrinter(AsmPrinterVariant, *AsmInfo, *STI));
235
#elif HAVE_LLVM >= 0x0208
217
   OwningPtr<MCInstPrinter> Printer(
236
   OwningPtr<MCInstPrinter> Printer(
218
         T->createMCInstPrinter(AsmPrinterVariant, *AsmInfo));
237
         T->createMCInstPrinter(AsmPrinterVariant, *AsmInfo));
219
#else
238
#else
Lines 253-259 lp_disassemble(const void* func) Link Here
253
272
254
      if (!DisAsm->getInstruction(Inst, Size, memoryObject,
273
      if (!DisAsm->getInstruction(Inst, Size, memoryObject,
255
                                 pc,
274
                                 pc,
256
                                 nulls())) {
275
#if HAVE_LLVM >= 0x0300
276
				  nulls(), nulls())) {
277
#else
278
				  nulls())) {
279
#endif
257
         debug_printf("invalid\n");
280
         debug_printf("invalid\n");
258
         pc += 1;
281
         pc += 1;
259
      }
282
      }
Lines 276-282 lp_disassemble(const void* func) Link Here
276
       * Print the instruction.
299
       * Print the instruction.
277
       */
300
       */
278
301
279
#if HAVE_LLVM >= 0x208
302
#if HAVE_LLVM >= 0x0300
303
      Printer->printInst(&Inst, Out, "");
304
#elif HAVE_LLVM >= 0x208
280
      Printer->printInst(&Inst, Out);
305
      Printer->printInst(&Inst, Out);
281
#else
306
#else
282
      Printer->printInst(&Inst);
307
      Printer->printInst(&Inst);
Lines 289-295 lp_disassemble(const void* func) Link Here
289
314
290
      pc += Size;
315
      pc += Size;
291
316
317
#if HAVE_LLVM >= 0x0300
318
      const MCInstrDesc &TID = TII->get(Inst.getOpcode());
319
#else
292
      const TargetInstrDesc &TID = TII->get(Inst.getOpcode());
320
      const TargetInstrDesc &TID = TII->get(Inst.getOpcode());
321
#endif
293
322
294
      /*
323
      /*
295
       * Keep track of forward jumps to a nearby address.
324
       * Keep track of forward jumps to a nearby address.
(-)a/src/gallium/auxiliary/gallivm/lp_bld_type.c (-2 / +4 lines)
Lines 325-340 lp_typekind_name(LLVMTypeKind t) Link Here
325
      return "LLVMArrayTypeKind";
325
      return "LLVMArrayTypeKind";
326
   case LLVMPointerTypeKind:
326
   case LLVMPointerTypeKind:
327
      return "LLVMPointerTypeKind";
327
      return "LLVMPointerTypeKind";
328
#if HAVE_LLVM < 0x0300
328
   case LLVMOpaqueTypeKind:
329
   case LLVMOpaqueTypeKind:
329
      return "LLVMOpaqueTypeKind";
330
      return "LLVMOpaqueTypeKind";
331
#endif
330
   case LLVMVectorTypeKind:
332
   case LLVMVectorTypeKind:
331
      return "LLVMVectorTypeKind";
333
      return "LLVMVectorTypeKind";
332
   case LLVMMetadataTypeKind:
334
   case LLVMMetadataTypeKind:
333
      return "LLVMMetadataTypeKind";
335
      return "LLVMMetadataTypeKind";
334
   /* Only in LLVM 2.7 and later???
336
#if HAVE_LLVM == 0x0207
335
   case LLVMUnionTypeKind:
337
   case LLVMUnionTypeKind:
336
      return "LLVMUnionTypeKind";
338
      return "LLVMUnionTypeKind";
337
   */
339
#endif
338
   default:
340
   default:
339
      return "unknown LLVMTypeKind";
341
      return "unknown LLVMTypeKind";
340
   }
342
   }
(-)a/src/gallium/drivers/llvmpipe/lp_jit.c (-4 / +15 lines)
Lines 68-77 lp_jit_create_types(struct llvmpipe_context *lp) Link Here
68
      elem_types[LP_JIT_TEXTURE_BORDER_COLOR] = 
68
      elem_types[LP_JIT_TEXTURE_BORDER_COLOR] = 
69
         LLVMArrayType(LLVMFloatTypeInContext(lc), 4);
69
         LLVMArrayType(LLVMFloatTypeInContext(lc), 4);
70
70
71
#if HAVE_LLVM >= 0x0300
72
   texture_type = LLVMStructCreateNamed(gallivm->context, "texture");
73
   LLVMStructSetBody(texture_type, elem_types,
74
                     Elements(elem_types), 0);
75
#else
71
      texture_type = LLVMStructTypeInContext(lc, elem_types,
76
      texture_type = LLVMStructTypeInContext(lc, elem_types,
72
                                             Elements(elem_types), 0);
77
                                             Elements(elem_types), 0);
78
      LLVMAddTypeName(gallivm->module, "texture", texture_type);
73
79
74
      LLVMInvalidateStructLayout(gallivm->target, texture_type);
80
      LLVMInvalidateStructLayout(gallivm->target, texture_type);
81
#endif
75
82
76
      LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, width,
83
      LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, width,
77
                             gallivm->target, texture_type,
84
                             gallivm->target, texture_type,
Lines 112-119 lp_jit_create_types(struct llvmpipe_context *lp) Link Here
112
119
113
      LP_CHECK_STRUCT_SIZE(struct lp_jit_texture,
120
      LP_CHECK_STRUCT_SIZE(struct lp_jit_texture,
114
                           gallivm->target, texture_type);
121
                           gallivm->target, texture_type);
115
116
      LLVMAddTypeName(gallivm->module, "texture", texture_type);
117
   }
122
   }
118
123
119
   /* struct lp_jit_context */
124
   /* struct lp_jit_context */
Lines 129-139 lp_jit_create_types(struct llvmpipe_context *lp) Link Here
129
      elem_types[LP_JIT_CTX_TEXTURES] = LLVMArrayType(texture_type,
134
      elem_types[LP_JIT_CTX_TEXTURES] = LLVMArrayType(texture_type,
130
                                                      PIPE_MAX_SAMPLERS);
135
                                                      PIPE_MAX_SAMPLERS);
131
136
137
#if HAVE_LLVM >= 0x0300
138
   context_type = LLVMStructCreateNamed(gallivm->context, "context");
139
   LLVMStructSetBody(context_type, elem_types,
140
                     Elements(elem_types), 0);
141
#else
132
      context_type = LLVMStructTypeInContext(lc, elem_types,
142
      context_type = LLVMStructTypeInContext(lc, elem_types,
133
                                             Elements(elem_types), 0);
143
                                             Elements(elem_types), 0);
134
144
135
      LLVMInvalidateStructLayout(gallivm->target, context_type);
145
      LLVMInvalidateStructLayout(gallivm->target, context_type);
136
146
147
      LLVMAddTypeName(gallivm->module, "context", context_type);
148
#endif
149
137
      LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, constants,
150
      LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, constants,
138
                             gallivm->target, context_type,
151
                             gallivm->target, context_type,
139
                             LP_JIT_CTX_CONSTANTS);
152
                             LP_JIT_CTX_CONSTANTS);
Lines 155-162 lp_jit_create_types(struct llvmpipe_context *lp) Link Here
155
      LP_CHECK_STRUCT_SIZE(struct lp_jit_context,
168
      LP_CHECK_STRUCT_SIZE(struct lp_jit_context,
156
                           gallivm->target, context_type);
169
                           gallivm->target, context_type);
157
170
158
      LLVMAddTypeName(gallivm->module, "context", context_type);
159
160
      lp->jit_context_ptr_type = LLVMPointerType(context_type, 0);
171
      lp->jit_context_ptr_type = LLVMPointerType(context_type, 0);
161
   }
172
   }
162
173

Return to bug 393013