mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-23 01:58:00 +02:00
Initial checkin
This commit is contained in:
parent
c74712dad9
commit
078564ac9e
3242 changed files with 1616395 additions and 0 deletions
135
IDEHelper/Backend/BeIRCodeGen.h
Normal file
135
IDEHelper/Backend/BeIRCodeGen.h
Normal file
|
@ -0,0 +1,135 @@
|
|||
#pragma once
|
||||
|
||||
#include "../Beef/BfCommon.h"
|
||||
#include "../Compiler/BfIRBuilder.h"
|
||||
#include "BeContext.h"
|
||||
#include "BeModule.h"
|
||||
|
||||
NS_BF_BEGIN
|
||||
|
||||
class BeModule;
|
||||
class BeDbgType;
|
||||
class BfIRBuilder;
|
||||
class ChunkedDataBuffer;
|
||||
|
||||
enum BeIRCodeGenEntryKind
|
||||
{
|
||||
BeIRCodeGenEntryKind_None,
|
||||
BeIRCodeGenEntryKind_Value,
|
||||
BeIRCodeGenEntryKind_Type,
|
||||
BeIRCodeGenEntryKind_Block,
|
||||
BeIRCodeGenEntryKind_Metadata
|
||||
};
|
||||
|
||||
struct BeIRCodeGenEntry
|
||||
{
|
||||
BeIRCodeGenEntryKind mKind;
|
||||
union
|
||||
{
|
||||
BeValue* mBeValue;
|
||||
BeType* mBeType;
|
||||
BeBlock* mBeBlock;
|
||||
BeMDNode* mBeMetadata;
|
||||
};
|
||||
};
|
||||
|
||||
class BeIRTypeEntry
|
||||
{
|
||||
public:
|
||||
int mTypeId;
|
||||
BeDbgType* mDIType;
|
||||
BeDbgType* mInstDIType;
|
||||
BeType* mBeType;
|
||||
BeType* mInstBeType;
|
||||
|
||||
public:
|
||||
BeIRTypeEntry()
|
||||
{
|
||||
mTypeId = -1;
|
||||
mDIType = NULL;
|
||||
mInstDIType = NULL;
|
||||
mBeType = NULL;
|
||||
mInstBeType = NULL;
|
||||
}
|
||||
};
|
||||
|
||||
class BeIRCodeGen : public BfIRCodeGenBase
|
||||
{
|
||||
public:
|
||||
bool mDebugging;
|
||||
|
||||
BfIRBuilder* mBfIRBuilder;
|
||||
BeFunction* mActiveFunction;
|
||||
|
||||
BeContext* mBeContext;
|
||||
BeModule* mBeModule;
|
||||
Array<BeDbgLoc*> mSavedDebugLocs;
|
||||
bool mHasDebugLoc;
|
||||
|
||||
int mCmdCount;
|
||||
Dictionary<int, BeIRCodeGenEntry> mResults;
|
||||
Dictionary<int, BeIRTypeEntry> mTypes;
|
||||
|
||||
Dictionary<BeType*, BeDbgType*> mOnDemandTypeMap;
|
||||
Array<int> mConfigConsts;
|
||||
|
||||
public:
|
||||
void NotImpl();
|
||||
BfTypeCode GetTypeCode(BeType* type, bool isSigned);
|
||||
void SetResult(int id, BeValue* value);
|
||||
void SetResult(int id, BeType* type);
|
||||
void SetResult(int id, BeBlock* value);
|
||||
void SetResult(int id, BeMDNode* md);
|
||||
|
||||
BeType* GetBeType(BfTypeCode typeCode, bool& isSigned);
|
||||
BeIRTypeEntry& GetTypeEntry(int typeId);
|
||||
|
||||
public:
|
||||
BeIRCodeGen();
|
||||
~BeIRCodeGen();
|
||||
|
||||
void Hash(BeHashContext& hashCtx);
|
||||
bool IsModuleEmpty();
|
||||
|
||||
int64 ReadSLEB128();
|
||||
void Read(StringImpl& str);
|
||||
void Read(int& i);
|
||||
void Read(int64& i);
|
||||
void Read(bool& val);
|
||||
void Read(BeIRTypeEntry*& type);
|
||||
void Read(BeType*& beType);
|
||||
void Read(BeFunctionType*& beType);
|
||||
void Read(BeValue*& beValue);
|
||||
void Read(BeConstant*& beConstant);
|
||||
void Read(BeFunction*& beFunc);
|
||||
void Read(BeBlock*& beBlock);
|
||||
void Read(BeMDNode*& beMD);
|
||||
|
||||
template <typename T>
|
||||
void Read(SizedArrayImpl<T>& vec)
|
||||
{
|
||||
int len = (int)ReadSLEB128();
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
T result;
|
||||
Read(result);
|
||||
vec.push_back(result);
|
||||
}
|
||||
}
|
||||
|
||||
void Init(const BfSizedArray<uint8>& buffer);
|
||||
void Process();
|
||||
|
||||
virtual void ProcessBfIRData(const BfSizedArray<uint8>& buffer) override;
|
||||
virtual void HandleNextCmd() override;
|
||||
virtual void SetConfigConst(int idx, int value) override;
|
||||
|
||||
BeValue* GetBeValue(int streamId);
|
||||
BeType* GetBeType(int streamId);
|
||||
BeBlock* GetBeBlock(int streamId);
|
||||
BeMDNode* GetBeMetadata(int streamId);
|
||||
|
||||
BeType* GetBeTypeById(int id);
|
||||
};
|
||||
|
||||
NS_BF_END
|
Loading…
Add table
Add a link
Reference in a new issue