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-04-28 20:55:13 +01:00
|
|
|
#include "IrValueLocationTracking.h"
|
2023-03-31 19:42:49 +01:00
|
|
|
|
2023-03-24 18:03:04 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace Luau
|
|
|
|
{
|
|
|
|
namespace CodeGen
|
|
|
|
{
|
|
|
|
|
|
|
|
struct ModuleHelpers;
|
|
|
|
struct AssemblyOptions;
|
|
|
|
|
|
|
|
namespace A64
|
|
|
|
{
|
|
|
|
|
|
|
|
struct IrLoweringA64
|
|
|
|
{
|
2023-06-24 07:19:39 +01:00
|
|
|
IrLoweringA64(AssemblyBuilderA64& build, ModuleHelpers& helpers, IrFunction& function);
|
2023-03-24 18:03:04 +00:00
|
|
|
|
|
|
|
void lowerInst(IrInst& inst, uint32_t index, IrBlock& next);
|
2023-04-21 23:14:26 +01:00
|
|
|
void finishBlock();
|
2023-06-16 18:35:18 +01:00
|
|
|
void finishFunction();
|
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;
|
|
|
|
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;
|
|
|
|
|
2023-06-16 18:35:18 +01:00
|
|
|
struct InterruptHandler
|
|
|
|
{
|
|
|
|
Label self;
|
|
|
|
unsigned int pcpos;
|
|
|
|
Label next;
|
|
|
|
};
|
|
|
|
|
2023-07-07 21:10:48 +01:00
|
|
|
struct ExitHandler
|
|
|
|
{
|
|
|
|
Label self;
|
|
|
|
unsigned int pcpos;
|
|
|
|
};
|
|
|
|
|
2023-03-24 18:03:04 +00:00
|
|
|
AssemblyBuilderA64& build;
|
|
|
|
ModuleHelpers& helpers;
|
|
|
|
|
|
|
|
IrFunction& function;
|
|
|
|
|
2023-03-31 19:42:49 +01:00
|
|
|
IrRegAllocA64 regs;
|
2023-04-14 19:06:22 +01:00
|
|
|
|
2023-04-28 20:55:13 +01:00
|
|
|
IrValueLocationTracking valueTracker;
|
|
|
|
|
2023-06-16 18:35:18 +01:00
|
|
|
std::vector<InterruptHandler> interruptHandlers;
|
2023-07-07 21:10:48 +01:00
|
|
|
std::vector<ExitHandler> exitHandlers;
|
2023-06-16 18:35:18 +01:00
|
|
|
|
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
|