diff options
Diffstat (limited to 'src/passes/InstrumentLocals.cpp')
-rw-r--r-- | src/passes/InstrumentLocals.cpp | 108 |
1 files changed, 59 insertions, 49 deletions
diff --git a/src/passes/InstrumentLocals.cpp b/src/passes/InstrumentLocals.cpp index 6b44af0ad..3845b0fee 100644 --- a/src/passes/InstrumentLocals.cpp +++ b/src/passes/InstrumentLocals.cpp @@ -43,13 +43,13 @@ // ) // ) -#include <wasm.h> -#include <wasm-builder.h> -#include <pass.h> -#include "shared-constants.h" -#include "asmjs/shared-constants.h" #include "asm_v_wasm.h" +#include "asmjs/shared-constants.h" #include "ir/function-type-utils.h" +#include "shared-constants.h" +#include <pass.h> +#include <wasm-builder.h> +#include <wasm.h> namespace wasm { @@ -68,59 +68,71 @@ struct InstrumentLocals : public WalkerPass<PostWalker<InstrumentLocals>> { Builder builder(*getModule()); Name import; switch (curr->type) { - case i32: import = get_i32; break; - case i64: return; // TODO - case f32: import = get_f32; break; - case f64: import = get_f64; break; - case v128: assert(false && "v128 not implemented yet"); - case none: WASM_UNREACHABLE(); - case unreachable: WASM_UNREACHABLE(); + case i32: + import = get_i32; + break; + case i64: + return; // TODO + case f32: + import = get_f32; + break; + case f64: + import = get_f64; + break; + case v128: + assert(false && "v128 not implemented yet"); + case none: + WASM_UNREACHABLE(); + case unreachable: + WASM_UNREACHABLE(); } replaceCurrent( - builder.makeCall( - import, - { - builder.makeConst(Literal(int32_t(id++))), - builder.makeConst(Literal(int32_t(curr->index))), - curr - }, - curr->type - ) - ); + builder.makeCall(import, + {builder.makeConst(Literal(int32_t(id++))), + builder.makeConst(Literal(int32_t(curr->index))), + curr}, + curr->type)); } void visitSetLocal(SetLocal* curr) { Builder builder(*getModule()); Name import; switch (curr->value->type) { - case i32: import = set_i32; break; - case i64: return; // TODO - case f32: import = set_f32; break; - case f64: import = set_f64; break; - case v128: assert(false && "v128 not implemented yet"); - case unreachable: return; // nothing to do here - case none: WASM_UNREACHABLE(); + case i32: + import = set_i32; + break; + case i64: + return; // TODO + case f32: + import = set_f32; + break; + case f64: + import = set_f64; + break; + case v128: + assert(false && "v128 not implemented yet"); + case unreachable: + return; // nothing to do here + case none: + WASM_UNREACHABLE(); } - curr->value = builder.makeCall( - import, - { - builder.makeConst(Literal(int32_t(id++))), - builder.makeConst(Literal(int32_t(curr->index))), - curr->value - }, - curr->value->type - ); + curr->value = + builder.makeCall(import, + {builder.makeConst(Literal(int32_t(id++))), + builder.makeConst(Literal(int32_t(curr->index))), + curr->value}, + curr->value->type); } void visitModule(Module* curr) { - addImport(curr, get_i32, "iiii"); - addImport(curr, get_i64, "jiij"); - addImport(curr, get_f32, "fiif"); - addImport(curr, get_f64, "diid"); - addImport(curr, set_i32, "iiii"); - addImport(curr, set_i64, "jiij"); - addImport(curr, set_f32, "fiif"); - addImport(curr, set_f64, "diid"); + addImport(curr, get_i32, "iiii"); + addImport(curr, get_i64, "jiij"); + addImport(curr, get_f32, "fiif"); + addImport(curr, get_f64, "diid"); + addImport(curr, set_i32, "iiii"); + addImport(curr, set_i64, "jiij"); + addImport(curr, set_f32, "fiif"); + addImport(curr, set_f64, "diid"); } private: @@ -138,8 +150,6 @@ private: } }; -Pass* createInstrumentLocalsPass() { - return new InstrumentLocals(); -} +Pass* createInstrumentLocalsPass() { return new InstrumentLocals(); } } // namespace wasm |