AMDGPU: Add core backend files for R600/SI codegen v6
[oota-llvm.git] / lib / Target / AMDGPU / AMDILUtilityFunctions.h
1 //===-- AMDILUtilityFunctions.h - AMDIL Utility Functions Header --------===//
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 // This file provides helper macros for expanding case statements.
11 //
12 //===----------------------------------------------------------------------===//
13 #ifndef AMDILUTILITYFUNCTIONS_H_
14 #define AMDILUTILITYFUNCTIONS_H_
15
16 // Macros that are used to help with switch statements for various data types
17 // However, these macro's do not return anything unlike the second set below.
18 #define ExpandCaseTo32bitIntTypes(Instr)  \
19 case Instr##_i32:
20
21 #define ExpandCaseTo32bitIntTruncTypes(Instr)  \
22 case Instr##_i32i8: \
23 case Instr##_i32i16: 
24
25 #define ExpandCaseToIntTypes(Instr) \
26     ExpandCaseTo32bitIntTypes(Instr)
27
28 #define ExpandCaseToIntTruncTypes(Instr) \
29     ExpandCaseTo32bitIntTruncTypes(Instr)
30
31 #define ExpandCaseToFloatTypes(Instr) \
32     case Instr##_f32:
33
34 #define ExpandCaseTo32bitScalarTypes(Instr) \
35     ExpandCaseTo32bitIntTypes(Instr) \
36 case Instr##_f32:
37
38 #define ExpandCaseToAllScalarTypes(Instr) \
39     ExpandCaseToFloatTypes(Instr) \
40 ExpandCaseToIntTypes(Instr)
41
42 #define ExpandCaseToAllScalarTruncTypes(Instr) \
43     ExpandCaseToFloatTruncTypes(Instr) \
44 ExpandCaseToIntTruncTypes(Instr)
45
46 #define ExpandCaseToAllTypes(Instr) \
47 ExpandCaseToAllScalarTypes(Instr)
48
49 #define ExpandCaseToAllTruncTypes(Instr) \
50 ExpandCaseToAllScalarTruncTypes(Instr)
51
52 // Macros that expand into  statements with return values
53 #define ExpandCaseTo32bitIntReturn(Instr, Return)  \
54 case Instr##_i32: return Return##_i32;
55
56 #define ExpandCaseToIntReturn(Instr, Return) \
57     ExpandCaseTo32bitIntReturn(Instr, Return)
58
59 #define ExpandCaseToFloatReturn(Instr, Return) \
60     case Instr##_f32: return Return##_f32;\
61
62 #define ExpandCaseToAllScalarReturn(Instr, Return) \
63     ExpandCaseToFloatReturn(Instr, Return) \
64 ExpandCaseToIntReturn(Instr, Return)
65
66 // These macros expand to common groupings of RegClass ID's
67 #define ExpandCaseTo1CompRegID \
68 case AMDGPU::GPRI32RegClassID: \
69 case AMDGPU::GPRF32RegClassID:
70
71 #define ExpandCaseTo32BitType(Instr) \
72 case Instr##_i32: \
73 case Instr##_f32:
74
75 #endif // AMDILUTILITYFUNCTIONS_H_