12 struct ast_expression;
19 fold(parser_t *parser);
22 // Bitmask describing which branches of a conditional to take after folding.
23 // Zero indicates all the branches can be removed.
24 // ON_TRUE means ON_FALSE can be removed.
25 // ON_FALSE means ON_TRUE can be removed.
26 // ON_TRUE | ON_FALSE means nothing can be removed.
32 bool generate(ir_builder *ir);
33 ast_expression *op(const oper_info *info, ast_expression **opexprs);
34 ast_expression *intrinsic(const char *intrinsic, size_t n_args, ast_expression **args);
36 static uint32_t cond_ternary(ast_value *condval, ast_ternary *branch);
37 static uint32_t cond_ifthen(ast_value *condval, ast_ifthen *branch);
39 static ast_expression *superfluous(ast_expression *left, ast_expression *right, int op);
40 static ast_expression *binary(lex_ctx_t ctx, int op, ast_expression *left, ast_expression *right);
42 ast_expression *constgen_float(qcfloat_t value, bool inexact);
43 ast_expression *constgen_vector(vec3_t value);
44 ast_expression *constgen_string(const char *str, bool translate);
45 ast_expression *constgen_string(const std::string &str, bool translate);
47 ast_value *imm_float(size_t index) const { return m_imm_float[index]; }
48 ast_value *imm_vector(size_t index) const { return m_imm_vector[index]; }
51 static qcfloat_t immvalue_float(ast_value *value);
52 static vec3_t immvalue_vector(ast_value *value);
53 static const char *immvalue_string(ast_value *value);
57 bool immediate_true(ast_value *v);
59 bool check_except_float_impl(void (*callback)(void), ast_value *a, ast_value *b);
60 bool check_inexact_float(ast_value *a, ast_value *b);
62 ast_expression *op_mul_vec(vec3_t vec, ast_value *sel, const char *set);
63 ast_expression *op_neg(ast_value *a);
64 ast_expression *op_not(ast_value *a);
65 ast_expression *op_add(ast_value *a, ast_value *b);
66 ast_expression *op_sub(ast_value *a, ast_value *b);
67 ast_expression *op_mul(ast_value *a, ast_value *b);
68 ast_expression *op_div(ast_value *a, ast_value *b);
69 ast_expression *op_mod(ast_value *a, ast_value *b);
70 ast_expression *op_bor(ast_value *a, ast_value *b);
71 ast_expression *op_band(ast_value *a, ast_value *b);
72 ast_expression *op_xor(ast_value *a, ast_value *b);
73 ast_expression *op_lshift(ast_value *a, ast_value *b);
74 ast_expression *op_rshift(ast_value *a, ast_value *b);
75 ast_expression *op_andor(ast_value *a, ast_value *b, float expr);
76 ast_expression *op_tern(ast_value *a, ast_value *b, ast_value *c);
77 ast_expression *op_exp(ast_value *a, ast_value *b);
78 ast_expression *op_lteqgt(ast_value *a, ast_value *b);
79 ast_expression *op_ltgt(ast_value *a, ast_value *b, bool lt);
80 ast_expression *op_cmp(ast_value *a, ast_value *b, bool ne);
81 ast_expression *op_bnot(ast_value *a);
82 ast_expression *op_cross(ast_value *a, ast_value *b);
83 ast_expression *op_length(ast_value *a);
85 ast_expression *intrinsic_isfinite(ast_value *a);
86 ast_expression *intrinsic_isinf(ast_value *a);
87 ast_expression *intrinsic_isnan(ast_value *a);
88 ast_expression *intrinsic_isnormal(ast_value *a);
89 ast_expression *intrinsic_signbit(ast_value *a);
90 ast_expression *intrinsic_acosh(ast_value *a);
91 ast_expression *intrinsic_asinh(ast_value *a);
92 ast_expression *intrinsic_atanh(ast_value *a);
93 ast_expression *intrinsic_exp(ast_value *a);
94 ast_expression *intrinsic_exp2(ast_value *a);
95 ast_expression *intrinsic_expm1(ast_value *a);
96 ast_expression *intrinsic_pow(ast_value *lhs, ast_value *rhs);
97 ast_expression *intrinsic_mod(ast_value *lhs, ast_value *rhs);
98 ast_expression *intrinsic_fabs(ast_value *a);
100 ast_expression* intrinsic_nan(void);
101 ast_expression* intrinsic_epsilon(void);
102 ast_expression* intrinsic_inf(void);
104 static qcfloat_t immvalue_float(ir_value *value);
105 static vec3_t immvalue_vector(ir_value *value);
107 static uint32_t cond(ast_value *condval, ast_ifthen *branch);
110 friend struct intrin;
112 std::vector<ast_value*> m_imm_float;
113 std::vector<ast_value*> m_imm_vector;
114 std::vector<ast_value*> m_imm_string;
115 hash_table_t *m_imm_string_untranslate; /* map<string, ast_value*> */
116 hash_table_t *m_imm_string_dotranslate; /* map<string, ast_value*> */