Skip to content

Commit aca7419

Browse files
author
Daniel Kroening
committed
do __builtin_convertvector
1 parent 35eb739 commit aca7419

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

src/ansi-c/c_typecheck_expr.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,10 @@ void c_typecheck_baset::typecheck_expr_main(exprt &expr)
294294
expr.make_bool(gcc_types_compatible_p(subtypes[0], subtypes[1]));
295295
expr.add_source_location()=source_location;
296296
}
297+
else if(expr.id()==ID_clang_builtin_convertvector)
298+
{
299+
typecheck_type(expr.type());
300+
}
297301
else if(expr.id()==ID_builtin_offsetof)
298302
typecheck_expr_builtin_offsetof(expr);
299303
else if(expr.id()==ID_string_constant)

src/ansi-c/parser.y

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ extern char *yyansi_ctext;
146146
%token TOK_CW_VAR_ARG_TYPEOF "_var_arg_typeof"
147147
%token TOK_BUILTIN_VA_ARG "__builtin_va_arg"
148148
%token TOK_GCC_BUILTIN_TYPES_COMPATIBLE_P "__builtin_types_compatible_p"
149+
%token TOK_CLANG_BUILTIN_CONVERTVECTOR "__builtin_convertvector"
149150
%token TOK_OFFSETOF "__offsetof"
150151
%token TOK_ALIGNOF "__alignof__"
151152
%token TOK_MSC_TRY "__try"
@@ -305,6 +306,7 @@ primary_expression:
305306
{ $$ = $2; }
306307
| statement_expression
307308
| gcc_builtin_expressions
309+
| clang_builtin_expressions
308310
| cw_builtin_expressions
309311
| offsetof
310312
| quantifier_expression
@@ -370,6 +372,16 @@ gcc_builtin_expressions:
370372
}
371373
;
372374

375+
clang_builtin_expressions:
376+
TOK_CLANG_BUILTIN_CONVERTVECTOR '(' assignment_expression ',' type_name ')'
377+
{
378+
$$=$1;
379+
stack($$).id(ID_clang_builtin_convertvector);
380+
mto($$, $3);
381+
stack($$).type().swap(stack($5));
382+
}
383+
;
384+
373385
cw_builtin_expressions:
374386
TOK_CW_VAR_ARG_TYPEOF '(' type_name ')'
375387
{

src/ansi-c/scanner.l

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,14 @@ void ansi_c_scanner_init()
589589
return make_identifier();
590590
}
591591

592+
"__builtin_convertvector" {
593+
if(PARSER.mode==configt::ansi_ct::flavourt::GCC ||
594+
PARSER.mode==configt::ansi_ct::flavourt::APPLE)
595+
{ loc(); return TOK_CLANG_BUILTIN_CONVERTVECTOR; }
596+
else
597+
return make_identifier();
598+
}
599+
592600
"__alignof__" { if(PARSER.mode==configt::ansi_ct::flavourt::GCC ||
593601
PARSER.mode==configt::ansi_ct::flavourt::APPLE ||
594602
PARSER.mode==configt::ansi_ct::flavourt::ARM)

src/util/irep_ids.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ IREP_ID_ONE(continuous_assign)
335335
IREP_ID_ONE(blocking_assign)
336336
IREP_ID_ONE(non_blocking_assign)
337337
IREP_ID_ONE(alignof)
338+
IREP_ID_ONE(clang_builtin_convertvector)
338339
IREP_ID_ONE(gcc_builtin_va_arg)
339340
IREP_ID_ONE(gcc_builtin_types_compatible_p)
340341
IREP_ID_ONE(gcc_builtin_va_arg_next)

0 commit comments

Comments
 (0)