math: array parameters can be NULL
[smatch.git] / target.h
blob8f79426c096ad480ed108fa82c521f828b5d71b2
1 #ifndef TARGET_H
2 #define TARGET_H
4 #include "machine.h"
6 extern struct symbol *size_t_ctype;
7 extern struct symbol *ssize_t_ctype;
8 extern struct symbol *intmax_ctype;
9 extern struct symbol *uintmax_ctype;
10 extern struct symbol *int64_ctype;
11 extern struct symbol *uint64_ctype;
12 extern struct symbol *int32_ctype;
13 extern struct symbol *uint32_ctype;
14 extern struct symbol *wchar_ctype;
15 extern struct symbol *wint_ctype;
18 * For "__attribute__((aligned))"
20 extern int max_alignment;
23 * Integer data types
25 extern int bits_in_bool;
26 extern int bits_in_char;
27 extern int bits_in_short;
28 extern int bits_in_int;
29 extern int bits_in_long;
30 extern int bits_in_longlong;
31 extern int bits_in_longlonglong;
33 extern int max_int_alignment;
36 * Floating point data types
38 extern int bits_in_float;
39 extern int bits_in_double;
40 extern int bits_in_longdouble;
42 extern int max_fp_alignment;
45 * Pointer data type
47 extern int bits_in_pointer;
48 extern int pointer_alignment;
51 * Enum data types
53 extern int bits_in_enum;
54 extern int enum_alignment;
56 struct asm_operand;
57 struct builtin_fn;
59 struct target {
60 enum machine mach;
61 enum bitness bitness;
62 unsigned int big_endian:1;
63 unsigned int unsigned_char:1;
64 unsigned int size_t_long:1;
65 unsigned int has_int128:1;
67 struct symbol *wchar;
68 struct symbol *wint;
70 unsigned int bits_in_longdouble;
71 unsigned int max_fp_alignment;
73 const struct target *target_32bit;
74 const struct target *target_64bit;
76 const struct builtin_fn *builtins;
78 void (*init)(const struct target *self);
79 void (*predefine)(const struct target *self);
80 const char *(*asm_constraint)(struct asm_operand *op, int c, const char *str);
83 extern const struct target target_default;
84 extern const struct target target_alpha;
85 extern const struct target target_arm;
86 extern const struct target target_arm64;
87 extern const struct target target_bfin;
88 extern const struct target target_m68k;
89 extern const struct target target_microblaze;
90 extern const struct target target_mips32;
91 extern const struct target target_mips64;
92 extern const struct target target_nios2;
93 extern const struct target target_ppc32;
94 extern const struct target target_ppc64;
95 extern const struct target target_riscv32;
96 extern const struct target target_riscv64;
97 extern const struct target target_s390;
98 extern const struct target target_s390x;
99 extern const struct target target_sparc32;
100 extern const struct target target_sparc64;
101 extern const struct target target_i386;
102 extern const struct target target_x86_64;
104 /* target.c */
105 extern const struct target *arch_target;
107 enum machine target_parse(const char *name);
108 void target_config(enum machine mach);
109 void target_init(void);
112 * Helper functions for converting bits to bytes and vice versa.
115 static inline int bits_to_bytes(int bits)
117 return bits >= 0 ? (bits + bits_in_char - 1) / bits_in_char : -1;
120 static inline int bytes_to_bits(int bytes)
122 return bytes * bits_in_char;
125 static inline unsigned long array_element_offset(unsigned long base_bits, int idx)
127 int fragment = base_bits % bits_in_char;
128 if (fragment)
129 base_bits += bits_in_char - fragment;
130 return base_bits * idx;
133 #endif