ELF format now supports 32-bit. Added ability to add instructions to a respective architecture that stores the op code.
This commit is contained in:
40
include/arctyx/compiler/Architecture.h
Normal file
40
include/arctyx/compiler/Architecture.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
#include <ehs/Array.h>
|
||||
|
||||
#include "Instruction.h"
|
||||
|
||||
class Architecture
|
||||
{
|
||||
private:
|
||||
ehs::UInt_64 id;
|
||||
ehs::Str_8 name;
|
||||
ehs::Array<Instruction> instructions;
|
||||
|
||||
public:
|
||||
Architecture();
|
||||
|
||||
Architecture(ehs::Str_8 name);
|
||||
|
||||
Architecture(Architecture &&arch) noexcept;
|
||||
|
||||
Architecture(const Architecture &arc);
|
||||
|
||||
Architecture &operator=(Architecture &&arc) noexcept;
|
||||
|
||||
Architecture &operator=(const Architecture &arc);
|
||||
|
||||
ehs::UInt_64 Id() const;
|
||||
|
||||
ehs::Str_8 GetName() const;
|
||||
|
||||
bool HasInstruction(const ehs::UInt_64 &id) const;
|
||||
|
||||
bool HasInstruction(const ehs::Str_8 &name) const;
|
||||
|
||||
const Instruction *GetInstruction(const ehs::UInt_64 &id) const;
|
||||
|
||||
const Instruction *GetInstruction(const ehs::Str_8 &name) const;
|
||||
|
||||
bool AddInstruction(Instruction ins);
|
||||
};
|
43
include/arctyx/compiler/Instruction.h
Normal file
43
include/arctyx/compiler/Instruction.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
#include <ehs/Str.h>
|
||||
#include <ehs/Types.h>
|
||||
|
||||
class Instruction
|
||||
{
|
||||
private:
|
||||
ehs::UInt_64 id;
|
||||
ehs::Str_8 name;
|
||||
ehs::UInt_8 size;
|
||||
ehs::Byte *code;
|
||||
|
||||
public:
|
||||
~Instruction();
|
||||
|
||||
Instruction();
|
||||
|
||||
Instruction(ehs::Str_8 name, const ehs::UInt_8 &size, ehs::Byte *code);
|
||||
|
||||
Instruction(ehs::Str_8 name, const ehs::UInt_64 &code);
|
||||
|
||||
Instruction(ehs::Str_8 name, const ehs::UInt_32 &code);
|
||||
|
||||
Instruction(ehs::Str_8 name, const ehs::UInt_16 &code);
|
||||
|
||||
Instruction(ehs::Str_8 name, const ehs::UInt_8 &code);
|
||||
|
||||
Instruction(Instruction &&ins) noexcept;
|
||||
|
||||
Instruction(const Instruction &ins);
|
||||
|
||||
Instruction &operator=(Instruction &&ins) noexcept;
|
||||
|
||||
Instruction &operator=(const Instruction &ins);
|
||||
|
||||
ehs::UInt_64 GetId() const;
|
||||
|
||||
ehs::Str_8 GetName() const;
|
||||
|
||||
ehs::UInt_8 GetSize() const;
|
||||
|
||||
ehs::Byte *GetCode() const;
|
||||
};
|
@@ -14,7 +14,8 @@
|
||||
#define ELFH_TYPE_DYN 0x03
|
||||
|
||||
/// True header sizes.
|
||||
#define ELFH_SIZE 64
|
||||
#define ELF_64_BIT_HEADER_SIZE 64
|
||||
#define ELF_32_BIT_HEADER_SIZE 52
|
||||
|
||||
class ELF
|
||||
{
|
||||
@@ -78,6 +79,10 @@ public:
|
||||
ehs::Serializer<ehs::UInt_64> Serialize() const;
|
||||
|
||||
private:
|
||||
void Serialize_64(ehs::Serializer<ehs::UInt_64> &data) const;
|
||||
|
||||
void Serialize_32(ehs::Serializer<ehs::UInt_64> &data) const;
|
||||
|
||||
void InitializeSections();
|
||||
|
||||
ehs::UInt_64 RetrieveSectionsOffset() const;
|
@@ -49,5 +49,10 @@ public:
|
||||
|
||||
ehs::UInt_64 GetAlign() const;
|
||||
|
||||
void Serialize(ehs::Serializer<ehs::UInt_64>& inData) const;
|
||||
void Serialize(const ehs::UInt_8 &bitDepth, ehs::Serializer<ehs::UInt_64>& inData) const;
|
||||
|
||||
private:
|
||||
void Serialize_64(ehs::Serializer<ehs::UInt_64> &data) const;
|
||||
|
||||
void Serialize_32(ehs::Serializer<ehs::UInt_64> &data) const;
|
||||
};
|
@@ -71,5 +71,10 @@ public:
|
||||
|
||||
ehs::Serializer<ehs::UInt_64>& GetData();
|
||||
|
||||
void Serialize(ehs::Serializer<ehs::UInt_64>& inData) const;
|
||||
void Serialize(const ehs::UInt_8 &bitDepth, ehs::Serializer<ehs::UInt_64>& inData) const;
|
||||
|
||||
private:
|
||||
void Serialize_64(ehs::Serializer<ehs::UInt_64> &data) const;
|
||||
|
||||
void Serialize_32(ehs::Serializer<ehs::UInt_64> &data) const;
|
||||
};
|
Reference in New Issue
Block a user