2023-03-24 18:03:04 +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/AssemblyBuilderA64.h"
|
|
|
|
#include "Luau/IrData.h"
|
|
|
|
|
2023-03-31 19:42:49 +01:00
|
|
|
#include "IrRegAllocA64.h"
|
|
|
|
|
2023-03-24 18:03:04 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
struct Proto;
|
|
|
|
|
|
|
|
namespace Luau
|
|
|
|
{
|
|
|
|
namespace CodeGen
|
|
|
|
{
|
|
|
|
|
|
|
|
struct ModuleHelpers;
|
|
|
|
struct NativeState;
|
|
|
|
struct AssemblyOptions;
|
|
|
|
|
|
|
|
namespace A64
|
|
|
|
{
|
|
|
|
|
|
|
|
struct IrLoweringA64
|
|
|
|
{
|
|
|
|
IrLoweringA64(AssemblyBuilderA64& build, ModuleHelpers& helpers, NativeState& data, Proto* proto, IrFunction& function);
|
|
|
|
|
|
|
|
void lowerInst(IrInst& inst, uint32_t index, IrBlock& next);
|
2023-04-21 23:14:26 +01:00
|
|
|
void finishBlock();
|
2023-03-24 18:03:04 +00:00
|
|
|
|
2023-04-07 22:01:29 +01:00
|
|
|
bool hasError() const;
|
|
|
|
|
2023-03-24 18:03:04 +00:00
|
|
|
bool isFallthroughBlock(IrBlock target, IrBlock next);
|
|
|
|
void jumpOrFallthrough(IrBlock& target, IrBlock& next);
|
|
|
|
|
2023-03-31 19:42:49 +01:00
|
|
|
// Operand data build helpers
|
2023-04-21 23:14:26 +01:00
|
|
|
// May emit data/address synthesis instructions
|
2023-03-31 19:42:49 +01:00
|
|
|
RegisterA64 tempDouble(IrOp op);
|
|
|
|
RegisterA64 tempInt(IrOp op);
|
2023-04-21 23:14:26 +01:00
|
|
|
RegisterA64 tempUint(IrOp op);
|
2023-03-31 19:42:49 +01:00
|
|
|
AddressA64 tempAddr(IrOp op, int offset);
|
|
|
|
|
2023-04-21 23:14:26 +01:00
|
|
|
// May emit restore instructions
|
|
|
|
RegisterA64 regOp(IrOp op);
|
2023-03-24 18:03:04 +00:00
|
|
|
|
2023-04-21 23:14:26 +01:00
|
|
|
// Operand data lookup helpers
|
2023-03-24 18:03:04 +00:00
|
|
|
IrConst constOp(IrOp op) const;
|
|
|
|
uint8_t tagOp(IrOp op) const;
|
|
|
|
bool boolOp(IrOp op) const;
|
|
|
|
int intOp(IrOp op) const;
|
|
|
|
unsigned uintOp(IrOp op) const;
|
|
|
|
double doubleOp(IrOp op) const;
|
|
|
|
|
|
|
|
IrBlock& blockOp(IrOp op) const;
|
|
|
|
Label& labelOp(IrOp op) const;
|
|
|
|
|
|
|
|
AssemblyBuilderA64& build;
|
|
|
|
ModuleHelpers& helpers;
|
|
|
|
NativeState& data;
|
|
|
|
Proto* proto = nullptr; // Temporarily required to provide 'Instruction* pc' to old emitInst* methods
|
|
|
|
|
|
|
|
IrFunction& function;
|
|
|
|
|
2023-03-31 19:42:49 +01:00
|
|
|
IrRegAllocA64 regs;
|
2023-04-14 19:06:22 +01:00
|
|
|
|
|
|
|
bool error = false;
|
2023-03-24 18:03:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace A64
|
|
|
|
} // namespace CodeGen
|
|
|
|
} // namespace Luau
|