summaryrefslogtreecommitdiff
path: root/src/parser/contexts.h
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2024-02-05 12:08:02 -0800
committerGitHub <noreply@github.com>2024-02-05 12:08:02 -0800
commitbe13e0f115c6627b286343368fb125e18d332486 (patch)
tree182ae3e4354e28100f12690ff22965edecd04f07 /src/parser/contexts.h
parented15efeedd33bbdbadfafabc812d70a792a9a06c (diff)
downloadbinaryen-be13e0f115c6627b286343368fb125e18d332486.tar.gz
binaryen-be13e0f115c6627b286343368fb125e18d332486.tar.bz2
binaryen-be13e0f115c6627b286343368fb125e18d332486.zip
[Parser] Parse v128.const (#6275)
Diffstat (limited to 'src/parser/contexts.h')
-rw-r--r--src/parser/contexts.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/parser/contexts.h b/src/parser/contexts.h
index 507a54342..c14a555c5 100644
--- a/src/parser/contexts.h
+++ b/src/parser/contexts.h
@@ -406,6 +406,20 @@ struct NullInstrParserCtx {
Result<> makeI64Const(Index, uint64_t) { return Ok{}; }
Result<> makeF32Const(Index, float) { return Ok{}; }
Result<> makeF64Const(Index, double) { return Ok{}; }
+ Result<> makeI8x16Const(Index, const std::array<uint8_t, 16>&) {
+ return Ok{};
+ }
+ Result<> makeI16x8Const(Index, const std::array<uint16_t, 8>&) {
+ return Ok{};
+ }
+ Result<> makeI32x4Const(Index, const std::array<uint32_t, 4>&) {
+ return Ok{};
+ }
+ Result<> makeI64x2Const(Index, const std::array<uint64_t, 2>&) {
+ return Ok{};
+ }
+ Result<> makeF32x4Const(Index, const std::array<float, 4>&) { return Ok{}; }
+ Result<> makeF64x2Const(Index, const std::array<double, 2>&) { return Ok{}; }
Result<> makeLoad(Index, Type, bool, int, bool, MemoryIdxT*, MemargT) {
return Ok{};
}
@@ -1542,6 +1556,54 @@ struct ParseDefsCtx : TypeParserCtx<ParseDefsCtx> {
return withLoc(pos, irBuilder.makeConst(Literal(c)));
}
+ Result<> makeI8x16Const(Index pos, const std::array<uint8_t, 16>& vals) {
+ std::array<Literal, 16> lanes;
+ for (size_t i = 0; i < 16; ++i) {
+ lanes[i] = Literal(uint32_t(vals[i]));
+ }
+ return withLoc(pos, irBuilder.makeConst(Literal(lanes)));
+ }
+
+ Result<> makeI16x8Const(Index pos, const std::array<uint16_t, 8>& vals) {
+ std::array<Literal, 8> lanes;
+ for (size_t i = 0; i < 8; ++i) {
+ lanes[i] = Literal(uint32_t(vals[i]));
+ }
+ return withLoc(pos, irBuilder.makeConst(Literal(lanes)));
+ }
+
+ Result<> makeI32x4Const(Index pos, const std::array<uint32_t, 4>& vals) {
+ std::array<Literal, 4> lanes;
+ for (size_t i = 0; i < 4; ++i) {
+ lanes[i] = Literal(vals[i]);
+ }
+ return withLoc(pos, irBuilder.makeConst(Literal(lanes)));
+ }
+
+ Result<> makeI64x2Const(Index pos, const std::array<uint64_t, 2>& vals) {
+ std::array<Literal, 2> lanes;
+ for (size_t i = 0; i < 2; ++i) {
+ lanes[i] = Literal(vals[i]);
+ }
+ return withLoc(pos, irBuilder.makeConst(Literal(lanes)));
+ }
+
+ Result<> makeF32x4Const(Index pos, const std::array<float, 4>& vals) {
+ std::array<Literal, 4> lanes;
+ for (size_t i = 0; i < 4; ++i) {
+ lanes[i] = Literal(vals[i]);
+ }
+ return withLoc(pos, irBuilder.makeConst(Literal(lanes)));
+ }
+
+ Result<> makeF64x2Const(Index pos, const std::array<double, 2>& vals) {
+ std::array<Literal, 2> lanes;
+ for (size_t i = 0; i < 2; ++i) {
+ lanes[i] = Literal(vals[i]);
+ }
+ return withLoc(pos, irBuilder.makeConst(Literal(lanes)));
+ }
+
Result<> makeLoad(Index pos,
Type type,
bool signed_,