2022-11-04 17:33:22 +00:00
|
|
|
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "Luau/RegisterA64.h"
|
|
|
|
|
2023-03-31 19:42:49 +01:00
|
|
|
#include <stddef.h>
|
|
|
|
|
2022-11-04 17:33:22 +00:00
|
|
|
namespace Luau
|
|
|
|
{
|
|
|
|
namespace CodeGen
|
|
|
|
{
|
2023-03-03 20:21:14 +00:00
|
|
|
namespace A64
|
|
|
|
{
|
2022-11-04 17:33:22 +00:00
|
|
|
|
|
|
|
enum class AddressKindA64 : uint8_t
|
|
|
|
{
|
2023-06-09 18:08:00 +01:00
|
|
|
reg, // reg + reg
|
|
|
|
imm, // reg + imm
|
|
|
|
pre, // reg + imm, reg += imm
|
|
|
|
post, // reg, reg += imm
|
2022-11-04 17:33:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct AddressA64
|
|
|
|
{
|
2023-03-31 19:42:49 +01:00
|
|
|
// This is a little misleading since AddressA64 can encode offsets up to 1023*size where size depends on the load/store size
|
|
|
|
// For example, ldr x0, [reg+imm] is limited to 8 KB offsets assuming imm is divisible by 8, but loading into w0 reduces the range to 4 KB
|
|
|
|
static constexpr size_t kMaxOffset = 1023;
|
|
|
|
|
2023-06-09 18:08:00 +01:00
|
|
|
constexpr AddressA64(RegisterA64 base, int off = 0, AddressKindA64 kind = AddressKindA64::imm)
|
|
|
|
: kind(kind)
|
2022-11-04 17:33:22 +00:00
|
|
|
, base(base)
|
|
|
|
, offset(xzr)
|
|
|
|
, data(off)
|
|
|
|
{
|
2024-02-16 02:04:39 +00:00
|
|
|
CODEGEN_ASSERT(base.kind == KindA64::x || base == sp);
|
|
|
|
CODEGEN_ASSERT(kind != AddressKindA64::reg);
|
2022-11-04 17:33:22 +00:00
|
|
|
}
|
|
|
|
|
2023-04-14 19:06:22 +01:00
|
|
|
constexpr AddressA64(RegisterA64 base, RegisterA64 offset)
|
2022-11-04 17:33:22 +00:00
|
|
|
: kind(AddressKindA64::reg)
|
|
|
|
, base(base)
|
|
|
|
, offset(offset)
|
|
|
|
, data(0)
|
|
|
|
{
|
2024-02-16 02:04:39 +00:00
|
|
|
CODEGEN_ASSERT(base.kind == KindA64::x);
|
|
|
|
CODEGEN_ASSERT(offset.kind == KindA64::x);
|
2022-11-04 17:33:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
AddressKindA64 kind;
|
|
|
|
RegisterA64 base;
|
|
|
|
RegisterA64 offset;
|
|
|
|
int data;
|
|
|
|
};
|
|
|
|
|
2022-11-10 22:53:13 +00:00
|
|
|
using mem = AddressA64;
|
|
|
|
|
2023-03-03 20:21:14 +00:00
|
|
|
} // namespace A64
|
2022-11-04 17:33:22 +00:00
|
|
|
} // namespace CodeGen
|
|
|
|
} // namespace Luau
|