| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584 |
- //-------------------------------------------------------------------------------------------------------
- // Copyright (C) Microsoft Corporation and contributors. All rights reserved.
- // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
- //-------------------------------------------------------------------------------------------------------
- #pragma once
- #ifdef ASMJS_PLAT
- namespace Js
- {
- ///----------------------------------------------------------------------------
- ///
- /// enum OpCodeAsmJs
- ///
- /// OpCodeAsmJs defines the set of p-code instructions available for byte-code in Asm.Js.
- ///
- ///----------------------------------------------------------------------------
- enum class OpCodeAsmJs : ushort {
- #define DEF_OP(x, y, ...) x,
- #include "OpCodeListAsmJs.h"
- MaxByteSizedOpcodes = 255,
- #include "ExtendedOpCodeListAsmJs.h"
- ByteCodeLast,
- #undef DEF_OP
- Count // Number of operations
- };
- inline OpCodeAsmJs operator+(OpCodeAsmJs o1, OpCodeAsmJs o2) { return (OpCodeAsmJs)((uint)o1 + (uint)o2); }
- inline uint operator+(OpCodeAsmJs o1, uint i) { return ((uint)o1 + i); }
- inline uint operator+(uint i, OpCodeAsmJs &o2) { return (i + (uint)o2); }
- inline OpCodeAsmJs operator++(OpCodeAsmJs &o) { return o = (OpCodeAsmJs)(o + 1U); }
- inline OpCodeAsmJs operator++(OpCodeAsmJs &o, int) { OpCodeAsmJs prev_o = o; o = (OpCodeAsmJs)(o + 1U); return prev_o; }
- inline OpCodeAsmJs operator-(OpCodeAsmJs o1, OpCodeAsmJs o2) { return (OpCodeAsmJs)((uint)o1 - (uint)o2); }
- inline uint operator-(OpCodeAsmJs o1, uint i) { return ((uint)o1 - i); }
- inline uint operator-(uint i, OpCodeAsmJs &o2) { return (i - (uint)o2); }
- inline OpCodeAsmJs operator--(OpCodeAsmJs &o) { return o = (OpCodeAsmJs)(o - 1U); }
- inline OpCodeAsmJs operator--(OpCodeAsmJs &o, int) { return o = (OpCodeAsmJs)(o - 1U); }
- inline uint operator<<(OpCodeAsmJs o1, uint i) { return ((uint)o1 << i); }
- inline OpCodeAsmJs& operator+=(OpCodeAsmJs &o, uint i) { return (o = (OpCodeAsmJs)(o + i)); }
- inline OpCodeAsmJs& operator-=(OpCodeAsmJs &o, uint i) { return (o = (OpCodeAsmJs)(o - i)); }
- inline bool operator==(OpCodeAsmJs &o, uint i) { return ((uint)(o) == i); }
- inline bool operator==(uint i, OpCodeAsmJs &o) { return (i == (uint)(o)); }
- inline bool operator!=(OpCodeAsmJs &o, uint i) { return ((uint)(o) != i); }
- inline bool operator!=(uint i, OpCodeAsmJs &o) { return (i != (uint)(o)); }
- inline bool operator<(OpCodeAsmJs &o, uint i) { return ((uint)(o) < i); }
- inline bool operator<(uint i, OpCodeAsmJs &o) { return (i < (uint)(o)); }
- inline bool operator<=(OpCodeAsmJs &o, uint i) { return ((uint)(o) <= i); }
- inline bool operator<=(uint i, OpCodeAsmJs &o) { return (i <= (uint)(o)); }
- inline bool operator<=(OpCodeAsmJs o1, OpCode o2) { return ((OpCode)o1 <= (o2)); }
- inline bool operator>(OpCodeAsmJs &o, uint i) { return ((uint)(o) > i); }
- inline bool operator>(uint i, OpCodeAsmJs &o) { return (i > (uint)(o)); }
- inline bool operator>=(OpCodeAsmJs &o, uint i) { return ((uint)(o) >= i); }
- inline bool operator>=(uint i, OpCodeAsmJs &o) { return (i >= (uint)(o)); }
- inline BOOL IsSimd128AsmJsOpcode(OpCodeAsmJs o)
- {
- return (o > Js::OpCodeAsmJs::Simd128_Start && o < Js::OpCodeAsmJs::Simd128_End) || (o > Js::OpCodeAsmJs::Simd128_Start_Extend && o < Js::OpCodeAsmJs::Simd128_End_Extend);
- }
- inline uint Simd128AsmJsOpcodeCount()
- {
- return (uint)(Js::OpCodeAsmJs::Simd128_End - Js::OpCodeAsmJs::Simd128_Start) + 1 + (uint)(Js::OpCodeAsmJs::Simd128_End_Extend - Js::OpCodeAsmJs::Simd128_Start_Extend) + 1;
- }
- ///----------------------------------------------------------------------------
- ///
- /// enum OpLayoutTypeAsmJs
- ///
- /// OpLayoutTypeAsmJs defines a set of layouts available for OpCodes. These layouts
- /// correspond to "OpLayout" structs defined below, such as "OpLayoutReg1".
- ///
- ///----------------------------------------------------------------------------
- BEGIN_ENUM_UINT( OpLayoutTypeAsmJs )
- // This define only one enum for each layout type, but not for each layout variant
- #define LAYOUT_TYPE(x) x,
- #define LAYOUT_TYPE_WMS LAYOUT_TYPE
- #include "LayoutTypesAsmJs.h"
- Count,
- END_ENUM_UINT()
- #pragma pack(push, 1)
- /// Asm.js Layout
- template <typename SizePolicy>
- struct OpLayoutT_AsmTypedArr
- {
- // force encode 4 bytes because it can be a value
- uint32 SlotIndex;
- typename SizePolicy::RegSlotType Value;
- Js::ArrayBufferView::ViewType ViewType;
- };
- template <typename SizePolicy>
- struct OpLayoutT_WasmMemAccess
- {
- uint32 Offset;
- typename SizePolicy::RegSlotType SlotIndex;
- typename SizePolicy::RegSlotType Value;
- Js::ArrayBufferView::ViewType ViewType;
- };
- template <typename SizePolicy>
- struct OpLayoutT_AsmCall
- {
- typename SizePolicy::ArgSlotType ArgCount;
- typename SizePolicy::RegSlotSType Return;
- typename SizePolicy::RegSlotType Function;
- int8 ReturnType;
- };
- template <typename SizePolicy>
- struct OpLayoutT_AsmReg1
- {
- typename SizePolicy::RegSlotType R0;
- };
- template <typename SizePolicy>
- struct OpLayoutT_AsmReg2
- {
- typename SizePolicy::RegSlotType R0;
- typename SizePolicy::RegSlotType R1;
- };
- template <typename SizePolicy>
- struct OpLayoutT_AsmReg3
- {
- typename SizePolicy::RegSlotType R0;
- typename SizePolicy::RegSlotType R1;
- typename SizePolicy::RegSlotType R2;
- };
- template <typename SizePolicy>
- struct OpLayoutT_AsmReg4
- {
- typename SizePolicy::RegSlotType R0;
- typename SizePolicy::RegSlotType R1;
- typename SizePolicy::RegSlotType R2;
- typename SizePolicy::RegSlotType R3;
- };
- template <typename SizePolicy>
- struct OpLayoutT_AsmReg5
- {
- typename SizePolicy::RegSlotType R0;
- typename SizePolicy::RegSlotType R1;
- typename SizePolicy::RegSlotType R2;
- typename SizePolicy::RegSlotType R3;
- typename SizePolicy::RegSlotType R4;
- };
- template <typename SizePolicy>
- struct OpLayoutT_AsmReg6
- {
- typename SizePolicy::RegSlotType R0;
- typename SizePolicy::RegSlotType R1;
- typename SizePolicy::RegSlotType R2;
- typename SizePolicy::RegSlotType R3;
- typename SizePolicy::RegSlotType R4;
- typename SizePolicy::RegSlotType R5;
- };
- template <typename SizePolicy>
- struct OpLayoutT_AsmReg7
- {
- typename SizePolicy::RegSlotType R0;
- typename SizePolicy::RegSlotType R1;
- typename SizePolicy::RegSlotType R2;
- typename SizePolicy::RegSlotType R3;
- typename SizePolicy::RegSlotType R4;
- typename SizePolicy::RegSlotType R5;
- typename SizePolicy::RegSlotType R6;
- };
- template <typename SizePolicy>
- struct OpLayoutT_AsmReg9
- {
- typename SizePolicy::RegSlotType R0;
- typename SizePolicy::RegSlotType R1;
- typename SizePolicy::RegSlotType R2;
- typename SizePolicy::RegSlotType R3;
- typename SizePolicy::RegSlotType R4;
- typename SizePolicy::RegSlotType R5;
- typename SizePolicy::RegSlotType R6;
- typename SizePolicy::RegSlotType R7;
- typename SizePolicy::RegSlotType R8;
- };
- template <typename SizePolicy>
- struct OpLayoutT_AsmReg10
- {
- typename SizePolicy::RegSlotType R0;
- typename SizePolicy::RegSlotType R1;
- typename SizePolicy::RegSlotType R2;
- typename SizePolicy::RegSlotType R3;
- typename SizePolicy::RegSlotType R4;
- typename SizePolicy::RegSlotType R5;
- typename SizePolicy::RegSlotType R6;
- typename SizePolicy::RegSlotType R7;
- typename SizePolicy::RegSlotType R8;
- typename SizePolicy::RegSlotType R9;
- };
- template <typename SizePolicy>
- struct OpLayoutT_AsmReg11
- {
- typename SizePolicy::RegSlotType R0;
- typename SizePolicy::RegSlotType R1;
- typename SizePolicy::RegSlotType R2;
- typename SizePolicy::RegSlotType R3;
- typename SizePolicy::RegSlotType R4;
- typename SizePolicy::RegSlotType R5;
- typename SizePolicy::RegSlotType R6;
- typename SizePolicy::RegSlotType R7;
- typename SizePolicy::RegSlotType R8;
- typename SizePolicy::RegSlotType R9;
- typename SizePolicy::RegSlotType R10;
- };
- template <typename SizePolicy>
- struct OpLayoutT_AsmReg17
- {
- typename SizePolicy::RegSlotType R0;
- typename SizePolicy::RegSlotType R1;
- typename SizePolicy::RegSlotType R2;
- typename SizePolicy::RegSlotType R3;
- typename SizePolicy::RegSlotType R4;
- typename SizePolicy::RegSlotType R5;
- typename SizePolicy::RegSlotType R6;
- typename SizePolicy::RegSlotType R7;
- typename SizePolicy::RegSlotType R8;
- typename SizePolicy::RegSlotType R9;
- typename SizePolicy::RegSlotType R10;
- typename SizePolicy::RegSlotType R11;
- typename SizePolicy::RegSlotType R12;
- typename SizePolicy::RegSlotType R13;
- typename SizePolicy::RegSlotType R14;
- typename SizePolicy::RegSlotType R15;
- typename SizePolicy::RegSlotType R16;
- };
- template <typename SizePolicy>
- struct OpLayoutT_AsmReg18
- {
- typename SizePolicy::RegSlotType R0;
- typename SizePolicy::RegSlotType R1;
- typename SizePolicy::RegSlotType R2;
- typename SizePolicy::RegSlotType R3;
- typename SizePolicy::RegSlotType R4;
- typename SizePolicy::RegSlotType R5;
- typename SizePolicy::RegSlotType R6;
- typename SizePolicy::RegSlotType R7;
- typename SizePolicy::RegSlotType R8;
- typename SizePolicy::RegSlotType R9;
- typename SizePolicy::RegSlotType R10;
- typename SizePolicy::RegSlotType R11;
- typename SizePolicy::RegSlotType R12;
- typename SizePolicy::RegSlotType R13;
- typename SizePolicy::RegSlotType R14;
- typename SizePolicy::RegSlotType R15;
- typename SizePolicy::RegSlotType R16;
- typename SizePolicy::RegSlotType R17;
- };
- template <typename SizePolicy>
- struct OpLayoutT_AsmReg19
- {
- typename SizePolicy::RegSlotType R0;
- typename SizePolicy::RegSlotType R1;
- typename SizePolicy::RegSlotType R2;
- typename SizePolicy::RegSlotType R3;
- typename SizePolicy::RegSlotType R4;
- typename SizePolicy::RegSlotType R5;
- typename SizePolicy::RegSlotType R6;
- typename SizePolicy::RegSlotType R7;
- typename SizePolicy::RegSlotType R8;
- typename SizePolicy::RegSlotType R9;
- typename SizePolicy::RegSlotType R10;
- typename SizePolicy::RegSlotType R11;
- typename SizePolicy::RegSlotType R12;
- typename SizePolicy::RegSlotType R13;
- typename SizePolicy::RegSlotType R14;
- typename SizePolicy::RegSlotType R15;
- typename SizePolicy::RegSlotType R16;
- typename SizePolicy::RegSlotType R17;
- typename SizePolicy::RegSlotType R18;
- };
- #define RegLayoutType typename SizePolicy::RegSlotType
- #define IntLayoutType typename SizePolicy::RegSlotType
- #define LongLayoutType typename SizePolicy::RegSlotType
- #define FloatLayoutType typename SizePolicy::RegSlotType
- #define DoubleLayoutType typename SizePolicy::RegSlotType
- #define IntConstLayoutType int
- #define LongConstLayoutType int64
- #define FloatConstLayoutType float
- #define DoubleConstLayoutType double
- #define Float32x4LayoutType typename SizePolicy::RegSlotType
- #define Bool32x4LayoutType typename SizePolicy::RegSlotType
- #define Int32x4LayoutType typename SizePolicy::RegSlotType
- #define Float64x2LayoutType typename SizePolicy::RegSlotType
- #define Int16x8LayoutType typename SizePolicy::RegSlotType
- #define Bool16x8LayoutType typename SizePolicy::RegSlotType
- #define Int8x16LayoutType typename SizePolicy::RegSlotType
- #define Bool8x16LayoutType typename SizePolicy::RegSlotType
- #define Uint32x4LayoutType typename SizePolicy::RegSlotType
- #define Uint16x8LayoutType typename SizePolicy::RegSlotType
- #define Uint8x16LayoutType typename SizePolicy::RegSlotType
- #define LAYOUT_FIELDS_HELPER(x, y) x ## y
- #define LAYOUT_FIELDS_DEF(x, y) LAYOUT_FIELDS_HELPER(x, y)
- #define LAYOUT_TYPE_WMS_REG2(layout, t0, t1) \
- template <typename SizePolicy> struct OpLayoutT_##layout\
- {\
- t0##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t0(), 0);\
- t1##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t1(), 1);\
- };
- #define LAYOUT_TYPE_WMS_REG3(layout, t0, t1, t2) \
- template <typename SizePolicy> struct OpLayoutT_##layout\
- {\
- t0##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t0(), 0);\
- t1##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t1(), 1);\
- t2##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t2(), 2);\
- };
- #define LAYOUT_TYPE_WMS_REG4(layout, t0, t1, t2, t3)\
- template <typename SizePolicy> struct OpLayoutT_##layout\
- {\
- t0##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t0(), 0);\
- t1##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t1(), 1);\
- t2##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t2(), 2);\
- t3##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t3(), 3);\
- };
- #define LAYOUT_TYPE_WMS_REG5(layout, t0, t1, t2, t3, t4)\
- template <typename SizePolicy> struct OpLayoutT_##layout\
- {\
- t0##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t0(), 0);\
- t1##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t1(), 1);\
- t2##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t2(), 2);\
- t3##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t3(), 3);\
- t4##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t4(), 4);\
- };
- #define LAYOUT_TYPE_WMS_REG6(layout, t0, t1, t2, t3, t4, t5)\
- template <typename SizePolicy> struct OpLayoutT_##layout\
- {\
- t0##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t0(), 0);\
- t1##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t1(), 1);\
- t2##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t2(), 2);\
- t3##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t3(), 3);\
- t4##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t4(), 4);\
- t5##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t5(), 5);\
- };
- #define LAYOUT_TYPE_WMS_REG7(layout, t0, t1, t2, t3, t4, t5, t6)\
- template <typename SizePolicy> struct OpLayoutT_##layout\
- {\
- t0##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t0(), 0);\
- t1##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t1(), 1);\
- t2##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t2(), 2);\
- t3##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t3(), 3);\
- t4##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t4(), 4);\
- t5##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t5(), 5);\
- t6##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t6(), 6);\
- };
- #define LAYOUT_TYPE_WMS_REG9(layout, t0, t1, t2, t3, t4, t5, t6, t7, t8)\
- template <typename SizePolicy> struct OpLayoutT_##layout\
- {\
- t0##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t0(), 0);\
- t1##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t1(), 1);\
- t2##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t2(), 2);\
- t3##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t3(), 3);\
- t4##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t4(), 4);\
- t5##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t5(), 5);\
- t6##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t6(), 6);\
- t7##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t7(), 7);\
- t8##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t8(), 8);\
- };
- #define LAYOUT_TYPE_WMS_REG10(layout, t0, t1, t2, t3, t4, t5, t6, t7, t8, t9)\
- template <typename SizePolicy> struct OpLayoutT_##layout\
- {\
- t0##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t0(), 0);\
- t1##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t1(), 1);\
- t2##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t2(), 2);\
- t3##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t3(), 3);\
- t4##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t4(), 4);\
- t5##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t5(), 5);\
- t6##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t6(), 6);\
- t7##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t7(), 7);\
- t8##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t8(), 8);\
- t9##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t9(), 9);\
- };
- #define LAYOUT_TYPE_WMS_REG11(layout, t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10)\
- template <typename SizePolicy> struct OpLayoutT_##layout\
- {\
- t0##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t0(), 0);\
- t1##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t1(), 1);\
- t2##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t2(), 2);\
- t3##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t3(), 3);\
- t4##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t4(), 4);\
- t5##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t5(), 5);\
- t6##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t6(), 6);\
- t7##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t7(), 7);\
- t8##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t8(), 8);\
- t9##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t9(), 9);\
- t10##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t10(), 10);\
- };
- #define LAYOUT_TYPE_WMS_REG17(layout, t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16)\
- template <typename SizePolicy> struct OpLayoutT_##layout\
- {\
- t0##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t0(), 0);\
- t1##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t1(), 1);\
- t2##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t2(), 2);\
- t3##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t3(), 3);\
- t4##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t4(), 4);\
- t5##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t5(), 5);\
- t6##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t6(), 6);\
- t7##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t7(), 7);\
- t8##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t8(), 8);\
- t9##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t9(), 9);\
- t10##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t10(), 10);\
- t11##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t11(), 11);\
- t12##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t12(), 12);\
- t13##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t13(), 13);\
- t14##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t14(), 14);\
- t15##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t15(), 15);\
- t16##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t16(), 16);\
- };
- #define LAYOUT_TYPE_WMS_REG18(layout, t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17)\
- template <typename SizePolicy> struct OpLayoutT_##layout\
- {\
- t0##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t0(), 0);\
- t1##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t1(), 1);\
- t2##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t2(), 2);\
- t3##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t3(), 3);\
- t4##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t4(), 4);\
- t5##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t5(), 5);\
- t6##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t6(), 6);\
- t7##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t7(), 7);\
- t8##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t8(), 8);\
- t9##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t9(), 9);\
- t10##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t10(), 10);\
- t11##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t11(), 11);\
- t12##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t12(), 12);\
- t13##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t13(), 13);\
- t14##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t14(), 14);\
- t15##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t15(), 15);\
- t16##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t16(), 16);\
- t17##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t17(), 17);\
- };
- #define LAYOUT_TYPE_WMS_REG19(layout, t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18)\
- template <typename SizePolicy> struct OpLayoutT_##layout\
- {\
- t0##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t0(), 0);\
- t1##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t1(), 1);\
- t2##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t2(), 2);\
- t3##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t3(), 3);\
- t4##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t4(), 4);\
- t5##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t5(), 5);\
- t6##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t6(), 6);\
- t7##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t7(), 7);\
- t8##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t8(), 8);\
- t9##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t9(), 9);\
- t10##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t10(), 10);\
- t11##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t11(), 11);\
- t12##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t12(), 12);\
- t13##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t13(), 13);\
- t14##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t14(), 14);\
- t15##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t15(), 15);\
- t16##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t16(), 16);\
- t17##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t17(), 17);\
- t18##LayoutType LAYOUT_FIELDS_DEF(LAYOUT_PREFIX_##t18(), 18);\
- };
- #include "LayoutTypesAsmJs.h"
- #undef RegLayoutType
- #undef IntLayoutType
- #undef LongLayoutType
- #undef FloatLayoutType
- #undef DoubleLayoutType
- #undef IntConstLayoutType
- #undef LongConstLayoutType
- #undef FloatConstLayoutType
- #undef DoubleConstLayoutType
- #undef Float32x4LayoutType
- #undef Bool32x4LayoutType
- #undef Int32x4LayoutType
- #undef Float64x2LayoutType
- #undef Int16x8LayoutType
- #undef Bool16x8LayoutType
- #undef Int8x16LayoutType
- #undef Bool8x16LayoutType
- #undef Uint32x4LayoutType
- #undef Uint16x8LayoutType
- #undef Uint8x16LayoutType
- template <typename SizePolicy>
- struct OpLayoutT_AsmUnsigned1
- {
- typename SizePolicy::UnsignedType C1;
- };
- struct OpLayoutAsmBr
- {
- int32 RelativeJumpOffset;
- };
- template <typename SizePolicy>
- struct OpLayoutT_BrInt1
- {
- int32 RelativeJumpOffset;
- typename SizePolicy::RegSlotType I1;
- };
- template <typename SizePolicy>
- struct OpLayoutT_BrInt2
- {
- int32 RelativeJumpOffset;
- typename SizePolicy::RegSlotType I1;
- typename SizePolicy::RegSlotType I2;
- };
- template <typename SizePolicy>
- struct OpLayoutT_BrInt1Const1
- {
- int32 RelativeJumpOffset;
- typename SizePolicy::RegSlotType I1;
- int32 C1;
- };
- template <typename SizePolicy>
- struct OpLayoutT_AsmSimdTypedArr
- {
- // force encode 4 bytes because it can be a value
- uint32 SlotIndex;
- typename SizePolicy::RegSlotType Value;
- ArrayBufferView::ViewType ViewType;
- int8 DataWidth; // # of bytes to load/store
- };
- // Generate the multi size layout type defs
- #define LAYOUT_TYPE_WMS(layout) \
- typedef OpLayoutT_##layout<LargeLayoutSizePolicy> OpLayout##layout##_Large; \
- typedef OpLayoutT_##layout<MediumLayoutSizePolicy> OpLayout##layout##_Medium; \
- typedef OpLayoutT_##layout<SmallLayoutSizePolicy> OpLayout##layout##_Small;
- #include "LayoutTypesAsmJs.h"
- #pragma pack(pop)
- // Generate structure to automatically map layout to its info
- template <OpLayoutTypeAsmJs::_E layout> struct OpLayoutInfoAsmJs;
- #define LAYOUT_TYPE(layout) \
- CompileAssert(sizeof(OpLayout##layout) <= MaxLayoutSize); \
- template <> struct OpLayoutInfoAsmJs<OpLayoutTypeAsmJs::layout> \
- { \
- static const bool HasMultiSizeLayout = false; \
- };
- #define LAYOUT_TYPE_WMS(layout) \
- CompileAssert(sizeof(OpLayout##layout##_Large) <= MaxLayoutSize); \
- template <> struct OpLayoutInfoAsmJs<OpLayoutTypeAsmJs::layout> \
- { \
- static const bool HasMultiSizeLayout = true; \
- };
- #include "LayoutTypesAsmJs.h"
- // Generate structure to automatically map opcode to its info
- // Also generate assert to make sure the layout and opcode use the same macro with and without multiple size layout
- template <OpCodeAsmJs opcode> struct OpCodeInfoAsmJs;
- #define DEFINE_OPCODEINFO(op, layout, extended) \
- CompileAssert(!OpLayoutInfoAsmJs<OpLayoutTypeAsmJs::layout>::HasMultiSizeLayout); \
- template <> struct OpCodeInfoAsmJs<OpCodeAsmJs::op> \
- { \
- static const OpLayoutTypeAsmJs::_E Layout = OpLayoutTypeAsmJs::layout; \
- static const bool HasMultiSizeLayout = false; \
- static const bool IsExtendedOpcode = extended; \
- typedef OpLayout##layout LayoutType; \
- };
- #define DEFINE_OPCODEINFO_WMS(op, layout, extended) \
- CompileAssert(OpLayoutInfoAsmJs<OpLayoutTypeAsmJs::layout>::HasMultiSizeLayout); \
- template <> struct OpCodeInfoAsmJs<OpCodeAsmJs::op> \
- { \
- static const OpLayoutTypeAsmJs::_E Layout = OpLayoutTypeAsmJs::layout; \
- static const bool HasMultiSizeLayout = true; \
- static const bool IsExtendedOpcode = extended; \
- typedef OpLayout##layout##_Large LayoutType_Large; \
- typedef OpLayout##layout##_Medium LayoutType_Medium; \
- typedef OpLayout##layout##_Small LayoutType_Small; \
- };
- #define MACRO(op, layout, ...) DEFINE_OPCODEINFO(op, layout, false)
- #define MACRO_WMS(op, layout, ...) DEFINE_OPCODEINFO_WMS(op, layout, false)
- #define MACRO_EXTEND(op, layout, ...) DEFINE_OPCODEINFO(op, layout, true)
- #define MACRO_EXTEND_WMS(op, layout, ...) DEFINE_OPCODEINFO_WMS(op, layout, true)
- #include "OpCodesAsmJs.h"
- #undef DEFINE_OPCODEINFO
- #undef DEFINE_OPCODEINFO_WMS
- }
- #endif
|