2022-10-14 20:48:41 +01:00
|
|
|
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2022-10-21 18:54:01 +01:00
|
|
|
#include "ltm.h"
|
|
|
|
|
2022-10-14 20:48:41 +01:00
|
|
|
typedef uint32_t Instruction;
|
|
|
|
typedef struct lua_TValue TValue;
|
|
|
|
|
|
|
|
namespace Luau
|
|
|
|
{
|
|
|
|
namespace CodeGen
|
|
|
|
{
|
|
|
|
|
|
|
|
class AssemblyBuilderX64;
|
2022-11-04 17:33:22 +00:00
|
|
|
enum class ConditionX64 : uint8_t;
|
2022-10-14 20:48:41 +01:00
|
|
|
struct Label;
|
2022-10-28 11:37:29 +01:00
|
|
|
struct ModuleHelpers;
|
2022-10-14 20:48:41 +01:00
|
|
|
|
2022-10-21 18:54:01 +01:00
|
|
|
void emitInstLoadNil(AssemblyBuilderX64& build, const Instruction* pc);
|
|
|
|
void emitInstLoadB(AssemblyBuilderX64& build, const Instruction* pc, int pcpos, Label* labelarr);
|
|
|
|
void emitInstLoadN(AssemblyBuilderX64& build, const Instruction* pc);
|
|
|
|
void emitInstLoadK(AssemblyBuilderX64& build, const Instruction* pc);
|
|
|
|
void emitInstLoadKX(AssemblyBuilderX64& build, const Instruction* pc);
|
|
|
|
void emitInstMove(AssemblyBuilderX64& build, const Instruction* pc);
|
2022-12-09 19:57:01 +00:00
|
|
|
void emitInstCall(AssemblyBuilderX64& build, ModuleHelpers& helpers, const Instruction* pc, int pcpos);
|
|
|
|
void emitInstReturn(AssemblyBuilderX64& build, ModuleHelpers& helpers, const Instruction* pc, int pcpos);
|
2022-10-21 18:54:01 +01:00
|
|
|
void emitInstJump(AssemblyBuilderX64& build, const Instruction* pc, int pcpos, Label* labelarr);
|
|
|
|
void emitInstJumpBack(AssemblyBuilderX64& build, const Instruction* pc, int pcpos, Label* labelarr);
|
|
|
|
void emitInstJumpIf(AssemblyBuilderX64& build, const Instruction* pc, int pcpos, Label* labelarr, bool not_);
|
|
|
|
void emitInstJumpIfEq(AssemblyBuilderX64& build, const Instruction* pc, int pcpos, Label* labelarr, bool not_, Label& fallback);
|
|
|
|
void emitInstJumpIfEqFallback(AssemblyBuilderX64& build, const Instruction* pc, int pcpos, Label* labelarr, bool not_);
|
2022-11-04 17:33:22 +00:00
|
|
|
void emitInstJumpIfCond(AssemblyBuilderX64& build, const Instruction* pc, int pcpos, Label* labelarr, ConditionX64 cond, Label& fallback);
|
|
|
|
void emitInstJumpIfCondFallback(AssemblyBuilderX64& build, const Instruction* pc, int pcpos, Label* labelarr, ConditionX64 cond);
|
2022-10-21 18:54:01 +01:00
|
|
|
void emitInstJumpX(AssemblyBuilderX64& build, const Instruction* pc, int pcpos, Label* labelarr);
|
|
|
|
void emitInstJumpxEqNil(AssemblyBuilderX64& build, const Instruction* pc, int pcpos, Label* labelarr);
|
|
|
|
void emitInstJumpxEqB(AssemblyBuilderX64& build, const Instruction* pc, int pcpos, Label* labelarr);
|
|
|
|
void emitInstJumpxEqN(AssemblyBuilderX64& build, const Instruction* pc, const TValue* k, int pcpos, Label* labelarr);
|
|
|
|
void emitInstJumpxEqS(AssemblyBuilderX64& build, const Instruction* pc, int pcpos, Label* labelarr);
|
2022-12-09 19:57:01 +00:00
|
|
|
void emitInstBinary(AssemblyBuilderX64& build, const Instruction* pc, TMS tm, Label& fallback);
|
2022-10-21 18:54:01 +01:00
|
|
|
void emitInstBinaryFallback(AssemblyBuilderX64& build, const Instruction* pc, int pcpos, TMS tm);
|
2022-12-09 19:57:01 +00:00
|
|
|
void emitInstBinaryK(AssemblyBuilderX64& build, const Instruction* pc, TMS tm, Label& fallback);
|
2022-10-21 18:54:01 +01:00
|
|
|
void emitInstBinaryKFallback(AssemblyBuilderX64& build, const Instruction* pc, int pcpos, TMS tm);
|
2022-12-09 19:57:01 +00:00
|
|
|
void emitInstPowK(AssemblyBuilderX64& build, const Instruction* pc, const TValue* k, Label& fallback);
|
2022-10-14 20:48:41 +01:00
|
|
|
void emitInstNot(AssemblyBuilderX64& build, const Instruction* pc);
|
2022-12-09 19:57:01 +00:00
|
|
|
void emitInstMinus(AssemblyBuilderX64& build, const Instruction* pc, Label& fallback);
|
2022-10-21 18:54:01 +01:00
|
|
|
void emitInstMinusFallback(AssemblyBuilderX64& build, const Instruction* pc, int pcpos);
|
2022-12-09 19:57:01 +00:00
|
|
|
void emitInstLength(AssemblyBuilderX64& build, const Instruction* pc, Label& fallback);
|
2022-10-21 18:54:01 +01:00
|
|
|
void emitInstLengthFallback(AssemblyBuilderX64& build, const Instruction* pc, int pcpos);
|
2022-12-09 19:57:01 +00:00
|
|
|
void emitInstNewTable(AssemblyBuilderX64& build, const Instruction* pc, int pcpos, Label& next);
|
|
|
|
void emitInstDupTable(AssemblyBuilderX64& build, const Instruction* pc, int pcpos, Label& next);
|
|
|
|
void emitInstSetList(AssemblyBuilderX64& build, const Instruction* pc, Label& next);
|
|
|
|
void emitInstGetUpval(AssemblyBuilderX64& build, const Instruction* pc);
|
|
|
|
void emitInstSetUpval(AssemblyBuilderX64& build, const Instruction* pc, Label& next);
|
|
|
|
void emitInstCloseUpvals(AssemblyBuilderX64& build, const Instruction* pc, Label& next);
|
|
|
|
int emitInstFastCall1(AssemblyBuilderX64& build, const Instruction* pc, int pcpos, Label& fallback);
|
|
|
|
int emitInstFastCall2(AssemblyBuilderX64& build, const Instruction* pc, int pcpos, Label& fallback);
|
|
|
|
int emitInstFastCall2K(AssemblyBuilderX64& build, const Instruction* pc, int pcpos, Label& fallback);
|
|
|
|
int emitInstFastCall(AssemblyBuilderX64& build, const Instruction* pc, int pcpos, Label& fallback);
|
|
|
|
void emitInstForNPrep(AssemblyBuilderX64& build, const Instruction* pc, int pcpos, Label& loopExit);
|
|
|
|
void emitInstForNLoop(AssemblyBuilderX64& build, const Instruction* pc, int pcpos, Label& loopRepeat);
|
|
|
|
void emitinstForGLoop(AssemblyBuilderX64& build, const Instruction* pc, int pcpos, Label& loopRepeat, Label& loopExit, Label& fallback);
|
|
|
|
void emitinstForGLoopFallback(AssemblyBuilderX64& build, const Instruction* pc, int pcpos, Label& loopRepeat);
|
|
|
|
void emitInstForGPrepNext(AssemblyBuilderX64& build, const Instruction* pc, Label& target, Label& fallback);
|
|
|
|
void emitInstForGPrepInext(AssemblyBuilderX64& build, const Instruction* pc, Label& target, Label& fallback);
|
|
|
|
void emitInstForGPrepXnextFallback(AssemblyBuilderX64& build, const Instruction* pc, int pcpos, Label& target);
|
2022-10-14 20:48:41 +01:00
|
|
|
void emitInstAnd(AssemblyBuilderX64& build, const Instruction* pc);
|
|
|
|
void emitInstAndK(AssemblyBuilderX64& build, const Instruction* pc);
|
|
|
|
void emitInstOr(AssemblyBuilderX64& build, const Instruction* pc);
|
|
|
|
void emitInstOrK(AssemblyBuilderX64& build, const Instruction* pc);
|
2022-12-09 19:57:01 +00:00
|
|
|
void emitInstGetTableN(AssemblyBuilderX64& build, const Instruction* pc, Label& fallback);
|
2022-10-21 18:54:01 +01:00
|
|
|
void emitInstGetTableNFallback(AssemblyBuilderX64& build, const Instruction* pc, int pcpos);
|
2022-12-09 19:57:01 +00:00
|
|
|
void emitInstSetTableN(AssemblyBuilderX64& build, const Instruction* pc, Label& next, Label& fallback);
|
2022-10-21 18:54:01 +01:00
|
|
|
void emitInstSetTableNFallback(AssemblyBuilderX64& build, const Instruction* pc, int pcpos);
|
2022-12-09 19:57:01 +00:00
|
|
|
void emitInstGetTable(AssemblyBuilderX64& build, const Instruction* pc, Label& fallback);
|
2022-10-21 18:54:01 +01:00
|
|
|
void emitInstGetTableFallback(AssemblyBuilderX64& build, const Instruction* pc, int pcpos);
|
2022-12-09 19:57:01 +00:00
|
|
|
void emitInstSetTable(AssemblyBuilderX64& build, const Instruction* pc, Label& next, Label& fallback);
|
2022-10-21 18:54:01 +01:00
|
|
|
void emitInstSetTableFallback(AssemblyBuilderX64& build, const Instruction* pc, int pcpos);
|
|
|
|
void emitInstGetImport(AssemblyBuilderX64& build, const Instruction* pc, Label& fallback);
|
2022-12-09 19:57:01 +00:00
|
|
|
void emitInstGetImportFallback(AssemblyBuilderX64& build, int ra, uint32_t aux);
|
2022-10-21 18:54:01 +01:00
|
|
|
void emitInstGetTableKS(AssemblyBuilderX64& build, const Instruction* pc, int pcpos, Label& fallback);
|
2022-12-09 19:57:01 +00:00
|
|
|
void emitInstSetTableKS(AssemblyBuilderX64& build, const Instruction* pc, int pcpos, Label& next, Label& fallback);
|
2022-10-21 18:54:01 +01:00
|
|
|
void emitInstGetGlobal(AssemblyBuilderX64& build, const Instruction* pc, int pcpos, Label& fallback);
|
2022-12-09 19:57:01 +00:00
|
|
|
void emitInstSetGlobal(AssemblyBuilderX64& build, const Instruction* pc, int pcpos, Label& next, Label& fallback);
|
|
|
|
void emitInstConcat(AssemblyBuilderX64& build, const Instruction* pc, int pcpos, Label& next);
|
2022-10-14 20:48:41 +01:00
|
|
|
|
|
|
|
} // namespace CodeGen
|
|
|
|
} // namespace Luau
|