@@ -501,6 +501,30 @@ DEF_CALL_HANDLER(emscripten_float32x4_storexy, {
501
501
return " SIMD_float32x4_storeXY(HEAPU8, " + getValueAsStr (CI->getOperand (0 )) + " , " + getValueAsStr (CI->getOperand (1 )) + " )" ;
502
502
})
503
503
504
+ // EM_ASM support
505
+
506
+ std::string handleAsmConst(const Instruction *CI, std::string suffix=" " ) {
507
+ std::string ret = " _emscripten_asm_const" + suffix + " (" + utostr (getAsmConstId (CI->getOperand (0 )));
508
+ unsigned Num = getNumArgOperands (CI);
509
+ for (unsigned i = 1 ; i < Num; i++) {
510
+ ret += " , " + getValueAsCastParenStr (CI->getOperand (i), ASM_NONSPECIFIC);
511
+ }
512
+ return ret + " )" ;
513
+ }
514
+
515
+ DEF_CALL_HANDLER (emscripten_asm_const, {
516
+ Declares.insert (" emscripten_asm_const" );
517
+ return handleAsmConst (CI);
518
+ })
519
+ DEF_CALL_HANDLER(emscripten_asm_const_int, {
520
+ Declares.insert (" emscripten_asm_const_int" );
521
+ return getAssign (CI) + getCast (handleAsmConst (CI, " _int" ), Type::getInt32Ty (CI->getContext ()));
522
+ })
523
+ DEF_CALL_HANDLER(emscripten_asm_const_double, {
524
+ Declares.insert (" emscripten_asm_const_double" );
525
+ return getAssign (CI) + getCast (handleAsmConst (CI, " _double" ), Type::getDoubleTy (CI->getContext ()));
526
+ })
527
+
504
528
#define DEF_BUILTIN_HANDLER (name, to ) \
505
529
DEF_CALL_HANDLER (name, { \
506
530
return CH___default__ (CI, #to); \
@@ -674,6 +698,9 @@ void setupCallHandlers() {
674
698
SETUP_CALL_HANDLER (emscripten_float32x4_loadxy);
675
699
SETUP_CALL_HANDLER (emscripten_float32x4_storex);
676
700
SETUP_CALL_HANDLER (emscripten_float32x4_storexy);
701
+ SETUP_CALL_HANDLER (emscripten_asm_const);
702
+ SETUP_CALL_HANDLER (emscripten_asm_const_int);
703
+ SETUP_CALL_HANDLER (emscripten_asm_const_double);
677
704
678
705
SETUP_CALL_HANDLER (abs );
679
706
SETUP_CALL_HANDLER (labs );
0 commit comments