aboutsummaryrefslogtreecommitdiff
path: root/backend/include/rcc/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'backend/include/rcc/CodeGen')
-rw-r--r--backend/include/rcc/CodeGen/GenericConstant.h176
-rw-r--r--backend/include/rcc/CodeGen/GlobalObject.h2
-rw-r--r--backend/include/rcc/CodeGen/MIRYamlMapping.h4
-rw-r--r--backend/include/rcc/CodeGen/MachineConstantPool.h2
-rw-r--r--backend/include/rcc/CodeGen/MachineMemOperand.h2
5 files changed, 5 insertions, 181 deletions
diff --git a/backend/include/rcc/CodeGen/GenericConstant.h b/backend/include/rcc/CodeGen/GenericConstant.h
deleted file mode 100644
index 4219c24..0000000
--- a/backend/include/rcc/CodeGen/GenericConstant.h
+++ /dev/null
@@ -1,176 +0,0 @@
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#ifndef RCC_CODEGEN_GENERICCONSTANT_H
-#define RCC_CODEGEN_GENERICCONSTANT_H
-
-#include "rcc/ADT/APFloat.h"
-#include "rcc/ADT/APInt.h"
-#include "rcc/CodeGen/LowLevelType.h"
-#include "rcc/Support/Error.h"
-
-#include <cstddef>
-#include <cstdint>
-#include <optional>
-#include <string>
-#include <vector>
-
-namespace rcc {
-
-enum class GenericConstantTypeKind : std::uint8_t {
- Invalid,
- Void,
- Label,
- Token,
- Metadata,
- Integer,
- Byte,
- Floating,
- Pointer,
- Array,
- Vector,
- Struct,
- Function,
- Named,
-};
-
-struct GenericConstantType final {
- GenericConstantTypeKind Kind = GenericConstantTypeKind::Invalid;
- std::uint32_t BitWidth = 0;
- FloatSemantics Semantics = FloatSemantics::IEEEHalf;
- std::uint32_t AddressSpace = 0;
- std::uint64_t ElementCount = 0;
- bool Scalable = false;
- bool Packed = false;
- bool VarArg = false;
- bool NumericName = false;
- std::string Name;
- std::vector<GenericConstantType> Elements;
-
- [[nodiscard]] static Expected<GenericConstantType> integer(std::uint32_t BitWidth);
- [[nodiscard]] static GenericConstantType primitive(GenericConstantTypeKind Kind) noexcept;
- [[nodiscard]] static GenericConstantType byte() noexcept;
- [[nodiscard]] static Expected<GenericConstantType> floating(FloatSemantics Semantics);
- [[nodiscard]] static GenericConstantType pointer(std::uint32_t AddressSpace = 0) noexcept;
- [[nodiscard]] static Expected<GenericConstantType> array(std::uint64_t ElementCount,
- GenericConstantType Element);
- [[nodiscard]] static Expected<GenericConstantType>
- vector(std::uint64_t ElementCount, GenericConstantType Element, bool Scalable = false);
- [[nodiscard]] static Expected<GenericConstantType>
- structure(std::vector<GenericConstantType> Elements, bool Packed = false);
- [[nodiscard]] static Expected<GenericConstantType>
- function(GenericConstantType Return, std::vector<GenericConstantType> Parameters,
- bool VarArg = false);
- [[nodiscard]] static Expected<GenericConstantType> named(std::string Name,
- bool NumericName = false);
-
- [[nodiscard]] Expected<void> verify() const;
-
- friend bool operator==(const GenericConstantType &Left,
- const GenericConstantType &Right) = default;
-};
-
-enum class GenericConstantKind : std::uint8_t {
- Invalid,
- Integer,
- Floating,
- NullPointer,
- ZeroInitializer,
- Undef,
- Poison,
- Aggregate,
- ByteString,
- GlobalAddress,
- BlockAddress,
- DSOLocalEquivalent,
- NoCFI,
- PointerAuth,
- Expression,
-};
-
-enum class GenericConstantExpressionOpcode : std::uint8_t {
- Invalid,
- Trunc,
- BitCast,
- AddressSpaceCast,
- IntToPtr,
- PtrToAddr,
- PtrToInt,
- Add,
- Sub,
- Xor,
- GetElementPtr,
- ShuffleVector,
- InsertElement,
- ExtractElement,
- Splat,
-};
-
-enum class GenericConstantExpressionFlag : std::uint8_t {
- NoUnsignedWrap,
- NoSignedWrap,
- InBounds,
- NoUnsignedSignedWrap,
- GEPNoUnsignedWrap,
- Count,
-};
-
-class GenericConstantExpressionFlags final {
-public:
- constexpr GenericConstantExpressionFlags() noexcept = default;
-
- [[nodiscard]] constexpr bool has(GenericConstantExpressionFlag Flag) const noexcept {
- const auto Index = static_cast<std::uint8_t>(Flag);
- if (Index >= static_cast<std::uint8_t>(GenericConstantExpressionFlag::Count))
- return false;
- return (Mask & (std::uint8_t{1} << Index)) != 0;
- }
-
- constexpr void set(GenericConstantExpressionFlag Flag) noexcept {
- const auto Index = static_cast<std::uint8_t>(Flag);
- if (Index < static_cast<std::uint8_t>(GenericConstantExpressionFlag::Count))
- Mask |= std::uint8_t{1} << Index;
- }
-
- [[nodiscard]] constexpr std::uint8_t rawValue() const noexcept {
- return Mask;
- }
-
- friend constexpr bool operator==(GenericConstantExpressionFlags Left,
- GenericConstantExpressionFlags Right) noexcept = default;
-
-private:
- std::uint8_t Mask = 0;
-};
-
-struct GenericConstantData final {
- GenericConstantType Type;
- GenericConstantKind Kind = GenericConstantKind::Invalid;
- std::optional<APInt> IntegerValue;
- std::optional<APFloat> FloatingValue;
- std::vector<std::byte> ByteValue;
- std::vector<GenericConstantData> Elements;
- std::string Symbol;
- std::string Block;
- bool NumericSymbol = false;
- bool NumericBlock = false;
- GenericConstantExpressionOpcode ExpressionOpcode = GenericConstantExpressionOpcode::Invalid;
- GenericConstantExpressionFlags ExpressionFlags;
- std::optional<GenericConstantType> SourceElementType;
- std::optional<APInt> InRangeStart;
- std::optional<APInt> InRangeEnd;
-
- [[nodiscard]] static Expected<GenericConstantData> integer(APInt Value);
- [[nodiscard]] static Expected<GenericConstantData> floating(APFloat Value);
- [[nodiscard]] static Expected<GenericConstantData> byteString(GenericConstantType Type,
- std::vector<std::byte> Bytes);
-
- [[nodiscard]] Expected<void> verify() const;
- [[nodiscard]] bool referencesSymbol() const noexcept;
-
- friend bool operator==(const GenericConstantData &Left,
- const GenericConstantData &Right) = default;
-};
-
-} // namespace rcc
-
-#endif // RCC_CODEGEN_GENERICCONSTANT_H
diff --git a/backend/include/rcc/CodeGen/GlobalObject.h b/backend/include/rcc/CodeGen/GlobalObject.h
index 798dcd8..1ddc34a 100644
--- a/backend/include/rcc/CodeGen/GlobalObject.h
+++ b/backend/include/rcc/CodeGen/GlobalObject.h
@@ -3,9 +3,9 @@
#ifndef RCC_CODEGEN_GLOBALOBJECT_H
#define RCC_CODEGEN_GLOBALOBJECT_H
-#include "rcc/CodeGen/GenericConstant.h"
#include "rcc/CodeGen/MachineIRTypes.h"
#include "rcc/CodeGen/TargetConstant.h"
+#include "rcc/IR/Constants.h"
#include "rcc/Support/Error.h"
#include <cstddef>
diff --git a/backend/include/rcc/CodeGen/MIRYamlMapping.h b/backend/include/rcc/CodeGen/MIRYamlMapping.h
index 82880ca..c25559b 100644
--- a/backend/include/rcc/CodeGen/MIRYamlMapping.h
+++ b/backend/include/rcc/CodeGen/MIRYamlMapping.h
@@ -9,7 +9,7 @@
#include "rcc/CodeGen/MachineJumpTableInfo.h"
#include "rcc/CodeGen/MachineMetadata.h"
#include "rcc/CodeGen/TargetMIRTextInfo.h"
-#include "rcc/MIR/LLVMConstantSyntax.h"
+#include "rcc/IR/DataLayout.h"
#include "rcc/Support/Error.h"
#include <cstdint>
@@ -106,7 +106,7 @@ private:
[[nodiscard]] bool convertTargetNode(const yaml::Node &Source, MIRTargetNode &Destination);
[[nodiscard]] bool validateDocumentReferences(const MachineFunction &Function);
[[nodiscard]] std::string_view effectiveDataLayout() const noexcept;
- [[nodiscard]] LLVMConstantSyntaxOptions pointerLayoutOptions() const noexcept;
+ [[nodiscard]] Expected<DataLayout> dataLayout() const;
[[nodiscard]] MachineBasicBlock *blockAt(MachineFunction &Function,
std::uint32_t Number) const noexcept;
diff --git a/backend/include/rcc/CodeGen/MachineConstantPool.h b/backend/include/rcc/CodeGen/MachineConstantPool.h
index a0c269b..104e559 100644
--- a/backend/include/rcc/CodeGen/MachineConstantPool.h
+++ b/backend/include/rcc/CodeGen/MachineConstantPool.h
@@ -3,10 +3,10 @@
#ifndef RCC_CODEGEN_MACHINECONSTANTPOOL_H
#define RCC_CODEGEN_MACHINECONSTANTPOOL_H
-#include "rcc/CodeGen/GenericConstant.h"
#include "rcc/CodeGen/MachineIRTypes.h"
#include "rcc/CodeGen/MachineMemOperand.h"
#include "rcc/CodeGen/TargetConstant.h"
+#include "rcc/IR/Constants.h"
#include "rcc/Support/Error.h"
#include <cstddef>
diff --git a/backend/include/rcc/CodeGen/MachineMemOperand.h b/backend/include/rcc/CodeGen/MachineMemOperand.h
index c5c1357..d236fd3 100644
--- a/backend/include/rcc/CodeGen/MachineMemOperand.h
+++ b/backend/include/rcc/CodeGen/MachineMemOperand.h
@@ -3,10 +3,10 @@
#ifndef RCC_CODEGEN_MACHINEMEMOPERAND_H
#define RCC_CODEGEN_MACHINEMEMOPERAND_H
-#include "rcc/CodeGen/GenericConstant.h"
#include "rcc/CodeGen/LowLevelType.h"
#include "rcc/CodeGen/MachineIRTypes.h"
#include "rcc/CodeGen/MachineMetadata.h"
+#include "rcc/IR/Constants.h"
#include <cstdint>
#include <initializer_list>