From 4ae73957c92d2141e161ad97cd2baa9f88fe7647 Mon Sep 17 00:00:00 2001 From: Atirut Wattanamongkol Date: Tue, 29 Oct 2024 10:42:38 +0700 Subject: [PATCH] Remove ZIR --- src/CMakeLists.txt | 1 - src/zir/CMakeLists.txt | 5 ----- src/zir/README.md | 2 -- src/zir/include/zir/instruction.hpp | 31 ----------------------------- src/zir/include/zir/module.hpp | 25 ----------------------- src/zir/instruction.cpp | 14 ------------- src/zir/module.cpp | 8 -------- 7 files changed, 86 deletions(-) delete mode 100644 src/zir/CMakeLists.txt delete mode 100644 src/zir/README.md delete mode 100644 src/zir/include/zir/instruction.hpp delete mode 100644 src/zir/include/zir/module.hpp delete mode 100644 src/zir/instruction.cpp delete mode 100644 src/zir/module.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9a11f929..b1b4271f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,3 +1,2 @@ add_subdirectory("cc") -add_subdirectory("zir") add_subdirectory("sdcc-wrapper") diff --git a/src/zir/CMakeLists.txt b/src/zir/CMakeLists.txt deleted file mode 100644 index 95e8dbb3..00000000 --- a/src/zir/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -add_library(zir STATIC - instruction.cpp - module.cpp -) -target_include_directories(zir PUBLIC include) diff --git a/src/zir/README.md b/src/zir/README.md deleted file mode 100644 index 9f381b41..00000000 --- a/src/zir/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# ZIR -This helper library is independent of the main compiler in hopes that it may be useful to other projects. It implements a simple TAC IR based on TACKY from Nora Sandler's [Writing a C Compiler](https://play.google.com/store/books/details/Nora_Sandler_Writing_a_C_Compiler?id=6StmEAAAQBAJ) book. diff --git a/src/zir/include/zir/instruction.hpp b/src/zir/include/zir/instruction.hpp deleted file mode 100644 index dc2f28da..00000000 --- a/src/zir/include/zir/instruction.hpp +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once -#include -#include -#include -#include - -namespace ZIR { - -typedef std::variant Value; - -// A three-address ZIR instruction -struct Instruction { -enum Operation { - // Return a value. - RETURN, - - // Complement a value. - COMPLEMENT, - // Negate a value. - NEGATE, -}; - - Operation operation; - std::optional result; - std::vector operands; - - Instruction(Operation operation); - Instruction(Operation operation, const Value &result); - Instruction &operator+=(const Value &operand); -}; -} // namespace ZIR diff --git a/src/zir/include/zir/module.hpp b/src/zir/include/zir/module.hpp deleted file mode 100644 index 5b62b35c..00000000 --- a/src/zir/include/zir/module.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once -#include "instruction.hpp" -#include -#include - -namespace ZIR { - -struct Module { - struct Symbol { - std::string name; - virtual ~Symbol() = default; - }; - - struct Function : public Symbol { - std::vector instructions; - // std::vector> locals; - - Function &operator+=(const Instruction &instruction); - }; - -// std::vector> symbols; - std::vector functions; -}; - -} // namespace ZIR diff --git a/src/zir/instruction.cpp b/src/zir/instruction.cpp deleted file mode 100644 index 378252b4..00000000 --- a/src/zir/instruction.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include - -using namespace std; -using namespace ZIR; - -Instruction::Instruction(Operation operation) : operation(operation) {} - -Instruction::Instruction(Operation operation, const Value &result) - : operation(operation), result(result) {} - -Instruction &Instruction::operator+=(const Value &operand) { - operands.push_back(operand); - return *this; -} diff --git a/src/zir/module.cpp b/src/zir/module.cpp deleted file mode 100644 index 34c2dc7c..00000000 --- a/src/zir/module.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include - -using namespace ZIR; - -Module::Function &Module::Function::operator+=(const Instruction &instruction) { - instructions.push_back(instruction); - return *this; -}