summaryrefslogtreecommitdiffstats
path: root/js/src/jit/wasm32/Architecture-wasm32.h
blob: d7726eaa5ffa17ef67fba28b1ab8a0d121c0e744 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
 * vim: set ts=8 sts=2 et sw=2 tw=80:
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef jit_wasm32_Architecture_wasm32_h
#define jit_wasm32_Architecture_wasm32_h

// JitSpewer.h is included through MacroAssembler implementations for other
// platforms, so include it here to avoid inadvertent build bustage.
#include "jit/JitSpewer.h"

#include "jit/shared/Architecture-shared.h"

namespace js::jit {

static const uint32_t SimdMemoryAlignment =
    4;  // Make it 4 to avoid a bunch of div-by-zero warnings
static const uint32_t WasmStackAlignment = 8;
static const uint32_t WasmTrapInstructionLength = 0;

// See comments in wasm::GenerateFunctionPrologue.
static constexpr uint32_t WasmCheckedCallEntryOffset = 0u;

class Registers {
 public:
  enum RegisterID {
    sp = 0,  // corresponds to global __stack_pointer which is mapped into
             // global[0]
    fp = 1,
    r2 = 2,
    r3 = 3,
    invalid_reg,
    invalid_reg2,  // To avoid silly static_assert failures.
  };
  typedef uint8_t Code;
  typedef RegisterID Encoding;
  union RegisterContent {
    uintptr_t r;
  };

  typedef uint8_t SetType;

  static uint32_t SetSize(SetType) { MOZ_CRASH(); }
  static uint32_t FirstBit(SetType) { MOZ_CRASH(); }
  static uint32_t LastBit(SetType) { MOZ_CRASH(); }
  static const char* GetName(Code) { MOZ_CRASH(); }
  static Code FromName(const char*) { MOZ_CRASH(); }

  static const Encoding StackPointer = RegisterID::sp;
  static const Encoding FramePointer = RegisterID::fp;
  static const Encoding Invalid = invalid_reg;
  static const uint32_t Total = 5;
  static const uint32_t TotalPhys = 0;
  static const uint32_t Allocatable = 0;
  static const SetType AllMask = 0;
  static const SetType ArgRegMask = 0;
  static const SetType VolatileMask = 0;
  static const SetType NonVolatileMask = 0;
  static const SetType NonAllocatableMask = 0;
  static const SetType AllocatableMask = 0;
  static const SetType JSCallMask = 0;
  static const SetType CallMask = 0;
};

typedef uint8_t PackedRegisterMask;

class FloatRegisters {
 public:
  enum FPRegisterID { f0 = 0, invalid_reg };
  typedef FPRegisterID Code;
  typedef FPRegisterID Encoding;
  union RegisterContent {
    float s;
    double d;
  };

  typedef uint32_t SetType;

  static const char* GetName(Code) { MOZ_CRASH(); }
  static Code FromName(const char*) { MOZ_CRASH(); }

  static const Code Invalid = invalid_reg;
  static const uint32_t Total = 0;
  static const uint32_t TotalPhys = 0;
  static const uint32_t Allocatable = 0;
  static const SetType AllMask = 0;
  static const SetType AllDoubleMask = 0;
  static const SetType AllSingleMask = 0;
  static const SetType VolatileMask = 0;
  static const SetType NonVolatileMask = 0;
  static const SetType NonAllocatableMask = 0;
  static const SetType AllocatableMask = 0;
};

template <typename T>
class TypedRegisterSet;

struct FloatRegister {
  typedef FloatRegisters Codes;
  typedef Codes::Code Code;
  typedef Codes::Encoding Encoding;
  typedef Codes::SetType SetType;

  Code _;

  static uint32_t FirstBit(SetType) { MOZ_CRASH(); }
  static uint32_t LastBit(SetType) { MOZ_CRASH(); }
  static FloatRegister FromCode(uint32_t) { MOZ_CRASH(); }
  bool isSingle() const { MOZ_CRASH(); }
  bool isDouble() const { MOZ_CRASH(); }
  bool isSimd128() const { MOZ_CRASH(); }
  bool isInvalid() const { MOZ_CRASH(); }
  FloatRegister asSingle() const { MOZ_CRASH(); }
  FloatRegister asDouble() const { MOZ_CRASH(); }
  FloatRegister asSimd128() const { MOZ_CRASH(); }
  Code code() const { MOZ_CRASH(); }
  Encoding encoding() const { MOZ_CRASH(); }
  const char* name() const { MOZ_CRASH(); }
  bool volatile_() const { MOZ_CRASH(); }
  bool operator!=(FloatRegister) const { MOZ_CRASH(); }
  bool operator==(FloatRegister) const { MOZ_CRASH(); }
  bool aliases(FloatRegister) const { MOZ_CRASH(); }
  uint32_t numAliased() const { MOZ_CRASH(); }
  FloatRegister aliased(uint32_t) { MOZ_CRASH(); }
  bool equiv(FloatRegister) const { MOZ_CRASH(); }
  uint32_t size() const { MOZ_CRASH(); }
  uint32_t numAlignedAliased() const { MOZ_CRASH(); }
  FloatRegister alignedAliased(uint32_t) { MOZ_CRASH(); }
  SetType alignedOrDominatedAliasedSet() const { MOZ_CRASH(); }

  static constexpr RegTypeName DefaultType = RegTypeName::Float64;

  template <RegTypeName = DefaultType>
  static SetType LiveAsIndexableSet(SetType s) {
    return SetType(0);
  }

  template <RegTypeName Name = DefaultType>
  static SetType AllocatableAsIndexableSet(SetType s) {
    static_assert(Name != RegTypeName::Any, "Allocatable set are not iterable");
    return SetType(0);
  }

  template <typename T>
  static T ReduceSetForPush(T) {
    MOZ_CRASH();
  }
  uint32_t getRegisterDumpOffsetInBytes() { MOZ_CRASH(); }
  static uint32_t SetSize(SetType x) { MOZ_CRASH(); }
  static Code FromName(const char* name) { MOZ_CRASH(); }

  // This is used in static initializers, so produce a bogus value instead of
  // crashing.
  static uint32_t GetPushSizeInBytes(const TypedRegisterSet<FloatRegister>&) {
    return 0;
  }
};

inline bool hasUnaliasedDouble() { MOZ_CRASH(); }
inline bool hasMultiAlias() { MOZ_CRASH(); }

static const uint32_t ShadowStackSpace = 0;
static const uint32_t JumpImmediateRange = INT32_MAX;

#ifdef JS_NUNBOX32
static const int32_t NUNBOX32_TYPE_OFFSET = 4;
static const int32_t NUNBOX32_PAYLOAD_OFFSET = 0;
#endif

}  // namespace js::jit

#endif /* jit_wasm32_Architecture_wasm32_h */