1*c0a41ee6SAnton Johansson /* 2*c0a41ee6SAnton Johansson * Copyright(c) 2019-2022 rev.ng Labs Srl. All Rights Reserved. 3*c0a41ee6SAnton Johansson * 4*c0a41ee6SAnton Johansson * This program is free software; you can redistribute it and/or modify 5*c0a41ee6SAnton Johansson * it under the terms of the GNU General Public License as published by 6*c0a41ee6SAnton Johansson * the Free Software Foundation; either version 2 of the License, or 7*c0a41ee6SAnton Johansson * (at your option) any later version. 8*c0a41ee6SAnton Johansson * 9*c0a41ee6SAnton Johansson * This program is distributed in the hope that it will be useful, 10*c0a41ee6SAnton Johansson * but WITHOUT ANY WARRANTY; without even the implied warranty of 11*c0a41ee6SAnton Johansson * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12*c0a41ee6SAnton Johansson * GNU General Public License for more details. 13*c0a41ee6SAnton Johansson * 14*c0a41ee6SAnton Johansson * You should have received a copy of the GNU General Public License 15*c0a41ee6SAnton Johansson * along with this program; if not, see <http://www.gnu.org/licenses/>. 16*c0a41ee6SAnton Johansson */ 17*c0a41ee6SAnton Johansson 18*c0a41ee6SAnton Johansson #ifndef PARSER_HELPERS_H 19*c0a41ee6SAnton Johansson #define PARSER_HELPERS_H 20*c0a41ee6SAnton Johansson 21*c0a41ee6SAnton Johansson #include <assert.h> 22*c0a41ee6SAnton Johansson #include <inttypes.h> 23*c0a41ee6SAnton Johansson #include <stdarg.h> 24*c0a41ee6SAnton Johansson #include <stdbool.h> 25*c0a41ee6SAnton Johansson #include <stdint.h> 26*c0a41ee6SAnton Johansson #include <stdio.h> 27*c0a41ee6SAnton Johansson #include <stdlib.h> 28*c0a41ee6SAnton Johansson #include <string.h> 29*c0a41ee6SAnton Johansson #include <unistd.h> 30*c0a41ee6SAnton Johansson 31*c0a41ee6SAnton Johansson #include "tcg/tcg-cond.h" 32*c0a41ee6SAnton Johansson 33*c0a41ee6SAnton Johansson #include "idef-parser.tab.h" 34*c0a41ee6SAnton Johansson #include "idef-parser.yy.h" 35*c0a41ee6SAnton Johansson #include "idef-parser.h" 36*c0a41ee6SAnton Johansson 37*c0a41ee6SAnton Johansson /* Decomment this to disable yyasserts */ 38*c0a41ee6SAnton Johansson /* #define NDEBUG */ 39*c0a41ee6SAnton Johansson 40*c0a41ee6SAnton Johansson #define ERR_LINE_CONTEXT 40 41*c0a41ee6SAnton Johansson 42*c0a41ee6SAnton Johansson #define START_COMMENT "/" "*" 43*c0a41ee6SAnton Johansson #define END_COMMENT "*" "/" 44*c0a41ee6SAnton Johansson 45*c0a41ee6SAnton Johansson void yyerror(YYLTYPE *locp, 46*c0a41ee6SAnton Johansson yyscan_t scanner __attribute__((unused)), 47*c0a41ee6SAnton Johansson Context *c, 48*c0a41ee6SAnton Johansson const char *s); 49*c0a41ee6SAnton Johansson 50*c0a41ee6SAnton Johansson #ifndef NDEBUG 51*c0a41ee6SAnton Johansson #define yyassert(context, locp, condition, msg) \ 52*c0a41ee6SAnton Johansson if (!(condition)) { \ 53*c0a41ee6SAnton Johansson yyerror(locp, (context)->scanner, (context), (msg)); \ 54*c0a41ee6SAnton Johansson } 55*c0a41ee6SAnton Johansson #endif 56*c0a41ee6SAnton Johansson 57*c0a41ee6SAnton Johansson bool is_direct_predicate(HexValue *value); 58*c0a41ee6SAnton Johansson 59*c0a41ee6SAnton Johansson bool is_inside_ternary(Context *c); 60*c0a41ee6SAnton Johansson 61*c0a41ee6SAnton Johansson /** 62*c0a41ee6SAnton Johansson * Print functions 63*c0a41ee6SAnton Johansson */ 64*c0a41ee6SAnton Johansson 65*c0a41ee6SAnton Johansson void str_print(Context *c, YYLTYPE *locp, const char *string); 66*c0a41ee6SAnton Johansson 67*c0a41ee6SAnton Johansson void uint8_print(Context *c, YYLTYPE *locp, uint8_t *num); 68*c0a41ee6SAnton Johansson 69*c0a41ee6SAnton Johansson void uint64_print(Context *c, YYLTYPE *locp, uint64_t *num); 70*c0a41ee6SAnton Johansson 71*c0a41ee6SAnton Johansson void int_print(Context *c, YYLTYPE *locp, int *num); 72*c0a41ee6SAnton Johansson 73*c0a41ee6SAnton Johansson void uint_print(Context *c, YYLTYPE *locp, unsigned *num); 74*c0a41ee6SAnton Johansson 75*c0a41ee6SAnton Johansson void tmp_print(Context *c, YYLTYPE *locp, HexTmp *tmp); 76*c0a41ee6SAnton Johansson 77*c0a41ee6SAnton Johansson void pred_print(Context *c, YYLTYPE *locp, HexPred *pred, bool is_dotnew); 78*c0a41ee6SAnton Johansson 79*c0a41ee6SAnton Johansson void reg_compose(Context *c, YYLTYPE *locp, HexReg *reg, char reg_id[5]); 80*c0a41ee6SAnton Johansson 81*c0a41ee6SAnton Johansson void reg_print(Context *c, YYLTYPE *locp, HexReg *reg); 82*c0a41ee6SAnton Johansson 83*c0a41ee6SAnton Johansson void imm_print(Context *c, YYLTYPE *locp, HexImm *imm); 84*c0a41ee6SAnton Johansson 85*c0a41ee6SAnton Johansson void var_print(Context *c, YYLTYPE *locp, HexVar *var); 86*c0a41ee6SAnton Johansson 87*c0a41ee6SAnton Johansson void rvalue_print(Context *c, YYLTYPE *locp, void *pointer); 88*c0a41ee6SAnton Johansson 89*c0a41ee6SAnton Johansson void out_assert(Context *c, YYLTYPE *locp, void *dummy); 90*c0a41ee6SAnton Johansson 91*c0a41ee6SAnton Johansson /** 92*c0a41ee6SAnton Johansson * Copies output code buffer into stdout 93*c0a41ee6SAnton Johansson */ 94*c0a41ee6SAnton Johansson void commit(Context *c); 95*c0a41ee6SAnton Johansson 96*c0a41ee6SAnton Johansson #define OUT_IMPL(c, locp, x) \ 97*c0a41ee6SAnton Johansson _Generic(*(x), \ 98*c0a41ee6SAnton Johansson char: str_print, \ 99*c0a41ee6SAnton Johansson uint8_t: uint8_print, \ 100*c0a41ee6SAnton Johansson uint64_t: uint64_print, \ 101*c0a41ee6SAnton Johansson int: int_print, \ 102*c0a41ee6SAnton Johansson unsigned: uint_print, \ 103*c0a41ee6SAnton Johansson HexValue: rvalue_print, \ 104*c0a41ee6SAnton Johansson default: out_assert \ 105*c0a41ee6SAnton Johansson )(c, locp, x); 106*c0a41ee6SAnton Johansson 107*c0a41ee6SAnton Johansson /* FOREACH macro */ 108*c0a41ee6SAnton Johansson #define FE_1(c, locp, WHAT, X) WHAT(c, locp, X) 109*c0a41ee6SAnton Johansson #define FE_2(c, locp, WHAT, X, ...) \ 110*c0a41ee6SAnton Johansson WHAT(c, locp, X)FE_1(c, locp, WHAT, __VA_ARGS__) 111*c0a41ee6SAnton Johansson #define FE_3(c, locp, WHAT, X, ...) \ 112*c0a41ee6SAnton Johansson WHAT(c, locp, X)FE_2(c, locp, WHAT, __VA_ARGS__) 113*c0a41ee6SAnton Johansson #define FE_4(c, locp, WHAT, X, ...) \ 114*c0a41ee6SAnton Johansson WHAT(c, locp, X)FE_3(c, locp, WHAT, __VA_ARGS__) 115*c0a41ee6SAnton Johansson #define FE_5(c, locp, WHAT, X, ...) \ 116*c0a41ee6SAnton Johansson WHAT(c, locp, X)FE_4(c, locp, WHAT, __VA_ARGS__) 117*c0a41ee6SAnton Johansson #define FE_6(c, locp, WHAT, X, ...) \ 118*c0a41ee6SAnton Johansson WHAT(c, locp, X)FE_5(c, locp, WHAT, __VA_ARGS__) 119*c0a41ee6SAnton Johansson #define FE_7(c, locp, WHAT, X, ...) \ 120*c0a41ee6SAnton Johansson WHAT(c, locp, X)FE_6(c, locp, WHAT, __VA_ARGS__) 121*c0a41ee6SAnton Johansson #define FE_8(c, locp, WHAT, X, ...) \ 122*c0a41ee6SAnton Johansson WHAT(c, locp, X)FE_7(c, locp, WHAT, __VA_ARGS__) 123*c0a41ee6SAnton Johansson #define FE_9(c, locp, WHAT, X, ...) \ 124*c0a41ee6SAnton Johansson WHAT(c, locp, X)FE_8(c, locp, WHAT, __VA_ARGS__) 125*c0a41ee6SAnton Johansson /* repeat as needed */ 126*c0a41ee6SAnton Johansson 127*c0a41ee6SAnton Johansson #define GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, NAME, ...) NAME 128*c0a41ee6SAnton Johansson 129*c0a41ee6SAnton Johansson #define FOR_EACH(c, locp, action, ...) \ 130*c0a41ee6SAnton Johansson do { \ 131*c0a41ee6SAnton Johansson GET_MACRO(__VA_ARGS__, \ 132*c0a41ee6SAnton Johansson FE_9, \ 133*c0a41ee6SAnton Johansson FE_8, \ 134*c0a41ee6SAnton Johansson FE_7, \ 135*c0a41ee6SAnton Johansson FE_6, \ 136*c0a41ee6SAnton Johansson FE_5, \ 137*c0a41ee6SAnton Johansson FE_4, \ 138*c0a41ee6SAnton Johansson FE_3, \ 139*c0a41ee6SAnton Johansson FE_2, \ 140*c0a41ee6SAnton Johansson FE_1)(c, locp, action, \ 141*c0a41ee6SAnton Johansson __VA_ARGS__) \ 142*c0a41ee6SAnton Johansson } while (0) 143*c0a41ee6SAnton Johansson 144*c0a41ee6SAnton Johansson #define OUT(c, locp, ...) FOR_EACH((c), (locp), OUT_IMPL, __VA_ARGS__) 145*c0a41ee6SAnton Johansson 146*c0a41ee6SAnton Johansson const char *cmp_swap(Context *c, YYLTYPE *locp, const char *type); 147*c0a41ee6SAnton Johansson 148*c0a41ee6SAnton Johansson /** 149*c0a41ee6SAnton Johansson * Temporary values creation 150*c0a41ee6SAnton Johansson */ 151*c0a41ee6SAnton Johansson 152*c0a41ee6SAnton Johansson HexValue gen_tmp(Context *c, 153*c0a41ee6SAnton Johansson YYLTYPE *locp, 154*c0a41ee6SAnton Johansson unsigned bit_width, 155*c0a41ee6SAnton Johansson HexSignedness signedness); 156*c0a41ee6SAnton Johansson 157*c0a41ee6SAnton Johansson HexValue gen_tmp_value(Context *c, 158*c0a41ee6SAnton Johansson YYLTYPE *locp, 159*c0a41ee6SAnton Johansson const char *value, 160*c0a41ee6SAnton Johansson unsigned bit_width, 161*c0a41ee6SAnton Johansson HexSignedness signedness); 162*c0a41ee6SAnton Johansson 163*c0a41ee6SAnton Johansson HexValue gen_imm_value(Context *c __attribute__((unused)), 164*c0a41ee6SAnton Johansson YYLTYPE *locp, 165*c0a41ee6SAnton Johansson int value, 166*c0a41ee6SAnton Johansson unsigned bit_width, 167*c0a41ee6SAnton Johansson HexSignedness signedness); 168*c0a41ee6SAnton Johansson 169*c0a41ee6SAnton Johansson HexValue gen_imm_qemu_tmp(Context *c, YYLTYPE *locp, unsigned bit_width, 170*c0a41ee6SAnton Johansson HexSignedness signedness); 171*c0a41ee6SAnton Johansson 172*c0a41ee6SAnton Johansson void gen_rvalue_free(Context *c, YYLTYPE *locp, HexValue *rvalue); 173*c0a41ee6SAnton Johansson 174*c0a41ee6SAnton Johansson HexValue rvalue_materialize(Context *c, YYLTYPE *locp, HexValue *rvalue); 175*c0a41ee6SAnton Johansson 176*c0a41ee6SAnton Johansson HexValue gen_rvalue_extend(Context *c, YYLTYPE *locp, HexValue *rvalue); 177*c0a41ee6SAnton Johansson 178*c0a41ee6SAnton Johansson HexValue gen_rvalue_truncate(Context *c, YYLTYPE *locp, HexValue *rvalue); 179*c0a41ee6SAnton Johansson 180*c0a41ee6SAnton Johansson void gen_varid_allocate(Context *c, 181*c0a41ee6SAnton Johansson YYLTYPE *locp, 182*c0a41ee6SAnton Johansson HexValue *varid, 183*c0a41ee6SAnton Johansson unsigned bit_width, 184*c0a41ee6SAnton Johansson HexSignedness signedness); 185*c0a41ee6SAnton Johansson 186*c0a41ee6SAnton Johansson /** 187*c0a41ee6SAnton Johansson * Code generation functions 188*c0a41ee6SAnton Johansson */ 189*c0a41ee6SAnton Johansson 190*c0a41ee6SAnton Johansson HexValue gen_bin_cmp(Context *c, 191*c0a41ee6SAnton Johansson YYLTYPE *locp, 192*c0a41ee6SAnton Johansson TCGCond type, 193*c0a41ee6SAnton Johansson HexValue *op1, 194*c0a41ee6SAnton Johansson HexValue *op2); 195*c0a41ee6SAnton Johansson 196*c0a41ee6SAnton Johansson HexValue gen_bin_op(Context *c, 197*c0a41ee6SAnton Johansson YYLTYPE *locp, 198*c0a41ee6SAnton Johansson OpType type, 199*c0a41ee6SAnton Johansson HexValue *op1, 200*c0a41ee6SAnton Johansson HexValue *op2); 201*c0a41ee6SAnton Johansson 202*c0a41ee6SAnton Johansson HexValue gen_cast_op(Context *c, 203*c0a41ee6SAnton Johansson YYLTYPE *locp, 204*c0a41ee6SAnton Johansson HexValue *src, 205*c0a41ee6SAnton Johansson unsigned target_width, 206*c0a41ee6SAnton Johansson HexSignedness signedness); 207*c0a41ee6SAnton Johansson 208*c0a41ee6SAnton Johansson /** 209*c0a41ee6SAnton Johansson * gen_extend_op extends a region of src_width_ptr bits stored in a 210*c0a41ee6SAnton Johansson * value_ptr to the size of dst_width. Note: src_width_ptr is a 211*c0a41ee6SAnton Johansson * HexValue * to handle the special case where it is unknown at 212*c0a41ee6SAnton Johansson * translation time. 213*c0a41ee6SAnton Johansson */ 214*c0a41ee6SAnton Johansson HexValue gen_extend_op(Context *c, 215*c0a41ee6SAnton Johansson YYLTYPE *locp, 216*c0a41ee6SAnton Johansson HexValue *src_width, 217*c0a41ee6SAnton Johansson unsigned dst_width, 218*c0a41ee6SAnton Johansson HexValue *value, 219*c0a41ee6SAnton Johansson HexSignedness signedness); 220*c0a41ee6SAnton Johansson 221*c0a41ee6SAnton Johansson void gen_rdeposit_op(Context *c, 222*c0a41ee6SAnton Johansson YYLTYPE *locp, 223*c0a41ee6SAnton Johansson HexValue *dst, 224*c0a41ee6SAnton Johansson HexValue *value, 225*c0a41ee6SAnton Johansson HexValue *begin, 226*c0a41ee6SAnton Johansson HexValue *width); 227*c0a41ee6SAnton Johansson 228*c0a41ee6SAnton Johansson void gen_deposit_op(Context *c, 229*c0a41ee6SAnton Johansson YYLTYPE *locp, 230*c0a41ee6SAnton Johansson HexValue *dst, 231*c0a41ee6SAnton Johansson HexValue *value, 232*c0a41ee6SAnton Johansson HexValue *index, 233*c0a41ee6SAnton Johansson HexCast *cast); 234*c0a41ee6SAnton Johansson 235*c0a41ee6SAnton Johansson HexValue gen_rextract_op(Context *c, 236*c0a41ee6SAnton Johansson YYLTYPE *locp, 237*c0a41ee6SAnton Johansson HexValue *src, 238*c0a41ee6SAnton Johansson unsigned begin, 239*c0a41ee6SAnton Johansson unsigned width); 240*c0a41ee6SAnton Johansson 241*c0a41ee6SAnton Johansson HexValue gen_extract_op(Context *c, 242*c0a41ee6SAnton Johansson YYLTYPE *locp, 243*c0a41ee6SAnton Johansson HexValue *src, 244*c0a41ee6SAnton Johansson HexValue *index, 245*c0a41ee6SAnton Johansson HexExtract *extract); 246*c0a41ee6SAnton Johansson 247*c0a41ee6SAnton Johansson HexValue gen_read_reg(Context *c, YYLTYPE *locp, HexValue *reg); 248*c0a41ee6SAnton Johansson 249*c0a41ee6SAnton Johansson void gen_write_reg(Context *c, YYLTYPE *locp, HexValue *reg, HexValue *value); 250*c0a41ee6SAnton Johansson 251*c0a41ee6SAnton Johansson void gen_assign(Context *c, 252*c0a41ee6SAnton Johansson YYLTYPE *locp, 253*c0a41ee6SAnton Johansson HexValue *dst, 254*c0a41ee6SAnton Johansson HexValue *value); 255*c0a41ee6SAnton Johansson 256*c0a41ee6SAnton Johansson HexValue gen_convround(Context *c, 257*c0a41ee6SAnton Johansson YYLTYPE *locp, 258*c0a41ee6SAnton Johansson HexValue *src); 259*c0a41ee6SAnton Johansson 260*c0a41ee6SAnton Johansson HexValue gen_round(Context *c, 261*c0a41ee6SAnton Johansson YYLTYPE *locp, 262*c0a41ee6SAnton Johansson HexValue *src, 263*c0a41ee6SAnton Johansson HexValue *position); 264*c0a41ee6SAnton Johansson 265*c0a41ee6SAnton Johansson HexValue gen_convround_n(Context *c, 266*c0a41ee6SAnton Johansson YYLTYPE *locp, 267*c0a41ee6SAnton Johansson HexValue *src, 268*c0a41ee6SAnton Johansson HexValue *pos); 269*c0a41ee6SAnton Johansson 270*c0a41ee6SAnton Johansson /** 271*c0a41ee6SAnton Johansson * Circular addressing mode with auto-increment 272*c0a41ee6SAnton Johansson */ 273*c0a41ee6SAnton Johansson void gen_circ_op(Context *c, 274*c0a41ee6SAnton Johansson YYLTYPE *locp, 275*c0a41ee6SAnton Johansson HexValue *addr, 276*c0a41ee6SAnton Johansson HexValue *increment, 277*c0a41ee6SAnton Johansson HexValue *modifier); 278*c0a41ee6SAnton Johansson 279*c0a41ee6SAnton Johansson HexValue gen_locnt_op(Context *c, YYLTYPE *locp, HexValue *src); 280*c0a41ee6SAnton Johansson 281*c0a41ee6SAnton Johansson HexValue gen_ctpop_op(Context *c, YYLTYPE *locp, HexValue *src); 282*c0a41ee6SAnton Johansson 283*c0a41ee6SAnton Johansson HexValue gen_rotl(Context *c, YYLTYPE *locp, HexValue *src, HexValue *n); 284*c0a41ee6SAnton Johansson 285*c0a41ee6SAnton Johansson HexValue gen_deinterleave(Context *c, YYLTYPE *locp, HexValue *mixed); 286*c0a41ee6SAnton Johansson 287*c0a41ee6SAnton Johansson HexValue gen_interleave(Context *c, 288*c0a41ee6SAnton Johansson YYLTYPE *locp, 289*c0a41ee6SAnton Johansson HexValue *odd, 290*c0a41ee6SAnton Johansson HexValue *even); 291*c0a41ee6SAnton Johansson 292*c0a41ee6SAnton Johansson HexValue gen_carry_from_add(Context *c, 293*c0a41ee6SAnton Johansson YYLTYPE *locp, 294*c0a41ee6SAnton Johansson HexValue *op1, 295*c0a41ee6SAnton Johansson HexValue *op2, 296*c0a41ee6SAnton Johansson HexValue *op3); 297*c0a41ee6SAnton Johansson 298*c0a41ee6SAnton Johansson void gen_addsat64(Context *c, 299*c0a41ee6SAnton Johansson YYLTYPE *locp, 300*c0a41ee6SAnton Johansson HexValue *dst, 301*c0a41ee6SAnton Johansson HexValue *op1, 302*c0a41ee6SAnton Johansson HexValue *op2); 303*c0a41ee6SAnton Johansson 304*c0a41ee6SAnton Johansson void gen_inst(Context *c, GString *iname); 305*c0a41ee6SAnton Johansson 306*c0a41ee6SAnton Johansson void gen_inst_init_args(Context *c, YYLTYPE *locp); 307*c0a41ee6SAnton Johansson 308*c0a41ee6SAnton Johansson void gen_inst_code(Context *c, YYLTYPE *locp); 309*c0a41ee6SAnton Johansson 310*c0a41ee6SAnton Johansson void gen_pred_assign(Context *c, YYLTYPE *locp, HexValue *left_pred, 311*c0a41ee6SAnton Johansson HexValue *right_pred); 312*c0a41ee6SAnton Johansson 313*c0a41ee6SAnton Johansson void gen_cancel(Context *c, YYLTYPE *locp); 314*c0a41ee6SAnton Johansson 315*c0a41ee6SAnton Johansson void gen_load_cancel(Context *c, YYLTYPE *locp); 316*c0a41ee6SAnton Johansson 317*c0a41ee6SAnton Johansson void gen_load(Context *c, YYLTYPE *locp, HexValue *size, 318*c0a41ee6SAnton Johansson HexSignedness signedness, HexValue *ea, HexValue *dst); 319*c0a41ee6SAnton Johansson 320*c0a41ee6SAnton Johansson void gen_store(Context *c, YYLTYPE *locp, HexValue *size, HexValue *ea, 321*c0a41ee6SAnton Johansson HexValue *src); 322*c0a41ee6SAnton Johansson 323*c0a41ee6SAnton Johansson void gen_sethalf(Context *c, YYLTYPE *locp, HexCast *sh, HexValue *n, 324*c0a41ee6SAnton Johansson HexValue *dst, HexValue *value); 325*c0a41ee6SAnton Johansson 326*c0a41ee6SAnton Johansson void gen_setbits(Context *c, YYLTYPE *locp, HexValue *hi, HexValue *lo, 327*c0a41ee6SAnton Johansson HexValue *dst, HexValue *value); 328*c0a41ee6SAnton Johansson 329*c0a41ee6SAnton Johansson unsigned gen_if_cond(Context *c, YYLTYPE *locp, HexValue *cond); 330*c0a41ee6SAnton Johansson 331*c0a41ee6SAnton Johansson unsigned gen_if_else(Context *c, YYLTYPE *locp, unsigned index); 332*c0a41ee6SAnton Johansson 333*c0a41ee6SAnton Johansson HexValue gen_rvalue_pred(Context *c, YYLTYPE *locp, HexValue *pred); 334*c0a41ee6SAnton Johansson 335*c0a41ee6SAnton Johansson HexValue gen_rvalue_var(Context *c, YYLTYPE *locp, HexValue *var); 336*c0a41ee6SAnton Johansson 337*c0a41ee6SAnton Johansson HexValue gen_rvalue_mpy(Context *c, YYLTYPE *locp, HexMpy *mpy, HexValue *op1, 338*c0a41ee6SAnton Johansson HexValue *op2); 339*c0a41ee6SAnton Johansson 340*c0a41ee6SAnton Johansson HexValue gen_rvalue_not(Context *c, YYLTYPE *locp, HexValue *value); 341*c0a41ee6SAnton Johansson 342*c0a41ee6SAnton Johansson HexValue gen_rvalue_notl(Context *c, YYLTYPE *locp, HexValue *value); 343*c0a41ee6SAnton Johansson 344*c0a41ee6SAnton Johansson HexValue gen_rvalue_sat(Context *c, YYLTYPE *locp, HexSat *sat, HexValue *n, 345*c0a41ee6SAnton Johansson HexValue *value); 346*c0a41ee6SAnton Johansson 347*c0a41ee6SAnton Johansson HexValue gen_rvalue_fscr(Context *c, YYLTYPE *locp, HexValue *value); 348*c0a41ee6SAnton Johansson 349*c0a41ee6SAnton Johansson HexValue gen_rvalue_abs(Context *c, YYLTYPE *locp, HexValue *value); 350*c0a41ee6SAnton Johansson 351*c0a41ee6SAnton Johansson HexValue gen_rvalue_neg(Context *c, YYLTYPE *locp, HexValue *value); 352*c0a41ee6SAnton Johansson 353*c0a41ee6SAnton Johansson HexValue gen_rvalue_brev(Context *c, YYLTYPE *locp, HexValue *value); 354*c0a41ee6SAnton Johansson 355*c0a41ee6SAnton Johansson HexValue gen_rvalue_ternary(Context *c, YYLTYPE *locp, HexValue *cond, 356*c0a41ee6SAnton Johansson HexValue *true_branch, HexValue *false_branch); 357*c0a41ee6SAnton Johansson 358*c0a41ee6SAnton Johansson const char *cond_to_str(TCGCond cond); 359*c0a41ee6SAnton Johansson 360*c0a41ee6SAnton Johansson void emit_header(Context *c); 361*c0a41ee6SAnton Johansson 362*c0a41ee6SAnton Johansson void emit_arg(Context *c, YYLTYPE *locp, HexValue *arg); 363*c0a41ee6SAnton Johansson 364*c0a41ee6SAnton Johansson void emit_footer(Context *c); 365*c0a41ee6SAnton Johansson 366*c0a41ee6SAnton Johansson void track_string(Context *c, GString *s); 367*c0a41ee6SAnton Johansson 368*c0a41ee6SAnton Johansson void free_variables(Context *c, YYLTYPE *locp); 369*c0a41ee6SAnton Johansson 370*c0a41ee6SAnton Johansson void free_instruction(Context *c); 371*c0a41ee6SAnton Johansson 372*c0a41ee6SAnton Johansson void assert_signedness(Context *c, 373*c0a41ee6SAnton Johansson YYLTYPE *locp, 374*c0a41ee6SAnton Johansson HexSignedness signedness); 375*c0a41ee6SAnton Johansson 376*c0a41ee6SAnton Johansson #endif /* PARSER_HELPERS_h */ 377