Skip to content

two further clang builtins #2698

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions regression/ansi-c/builtin_ia32_undef/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
int main()
{
#ifdef __clang__
long long A __attribute__ ((__vector_size__ (16))) =
__builtin_ia32_undef128();
long long B __attribute__ ((__vector_size__ (32))) =
__builtin_ia32_undef256();
long long C __attribute__ ((__vector_size__ (64))) =
__builtin_ia32_undef512();
#endif
}
6 changes: 6 additions & 0 deletions regression/ansi-c/builtin_ia32_undef/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CORE
main.c

^EXIT=0$
^SIGNAL=0$
--
8 changes: 8 additions & 0 deletions regression/ansi-c/builtin_nontemporal_load_store/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
int main()
{
#ifdef __clang__
int var, value;
__builtin_nontemporal_store(1, &var);
value = __builtin_nontemporal_load(&var);
#endif
}
6 changes: 6 additions & 0 deletions regression/ansi-c/builtin_nontemporal_load_store/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CORE
main.c

^EXIT=0$
^SIGNAL=0$
--
30 changes: 30 additions & 0 deletions src/ansi-c/c_typecheck_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,12 @@ void c_typecheck_baset::typecheck_expr_main(exprt &expr)
}
else if(expr.id()==ID_clang_builtin_convertvector)
{
// This has one operand and a type, and acts like a typecast
DATA_INVARIANT(expr.operands().size()==1, "clang_builtin_convertvector has one operand");
typecheck_type(expr.type());
typecast_exprt tmp(expr.op0(), expr.type());
tmp.add_source_location()=expr.source_location();
expr.swap(tmp);
}
else if(expr.id()==ID_builtin_offsetof)
typecheck_expr_builtin_offsetof(expr);
Expand Down Expand Up @@ -2192,6 +2197,31 @@ exprt c_typecheck_baset::do_special_functions(

return bswap_expr;
}
else if(identifier=="__builtin_nontemporal_load")
{
typecheck_function_call_arguments(expr);

if(expr.arguments().size()!=1)
{
err_location(f_op);
error() << identifier << " expects one operand" << eom;
throw 0;
}

// these return the subtype of the argument
exprt &ptr_arg=expr.arguments().front();

if(ptr_arg.type().id()!=ID_pointer)
{
err_location(f_op);
error() << "__builtin_nontemporal_load takes pointer as argument" << eom;
throw 0;
}

expr.type()=expr.arguments().front().type().subtype();

return expr;
}
else if(
identifier == "__builtin_fpclassify" ||
identifier == CPROVER_PREFIX "fpclassify")
Expand Down
7 changes: 7 additions & 0 deletions src/ansi-c/clang_builtin_headers.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
__gcc_v4sf __builtin_shufflevector(__gcc_v4sf, __gcc_v4sf, ...);

__gcc_v2di __builtin_ia32_undef128(void);
__gcc_v4di __builtin_ia32_undef256(void);
__gcc_v8di __builtin_ia32_undef512(void);

void __builtin_nontemporal_store();
void __builtin_nontemporal_load();

int __builtin_flt_rounds(void);