mini-llvm 0.1.0
Loading...
Searching...
No Matches
Alloca.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2
3#pragma once
4
5#include <memory>
6#include <string>
7#include <unordered_set>
8#include <utility>
9
12#include "mini-llvm/ir/Type.h"
14#include "mini-llvm/ir/Value.h"
16
17namespace mini_llvm::ir {
18
19class MINI_LLVM_EXPORT Alloca final : public Instruction {
20public:
21 explicit Alloca(std::unique_ptr<Type> allocatedType) : allocatedType_(std::move(allocatedType)) {}
22
23 std::unique_ptr<Type> allocatedType() const {
24 return allocatedType_->clone();
25 }
26
27 std::unordered_set<const UseBase *> operands() const override {
28 return {};
29 }
30
31 void accept(InstructionVisitor &visitor) override {
32 visitor.visitAlloca(*this);
33 }
34
35 void accept(InstructionVisitor &visitor) const override {
36 visitor.visitAlloca(*this);
37 }
38
39 bool isWellFormed() const override;
40
41 std::unique_ptr<Type> type() const override {
42 return std::make_unique<Ptr>();
43 }
44
45 std::string format() const override;
46 std::unique_ptr<Value> clone() const override;
47
48private:
49 std::unique_ptr<Type> allocatedType_;
50};
51
52} // namespace mini_llvm::ir
#define MINI_LLVM_EXPORT
Definition Compiler.h:17
std::unordered_set< const UseBase * > operands() const override
Definition Alloca.h:27
std::unique_ptr< Type > type() const override
Definition Alloca.h:41
std::unique_ptr< Type > allocatedType() const
Definition Alloca.h:23
bool isWellFormed() const override
void accept(InstructionVisitor &visitor) const override
Definition Alloca.h:35
void accept(InstructionVisitor &visitor) override
Definition Alloca.h:31
Alloca(std::unique_ptr< Type > allocatedType)
Definition Alloca.h:21
std::string format() const override
std::unique_ptr< Value > clone() const override
Definition InstructionVisitor.h:58
virtual void visitAlloca(Alloca &I)
Definition InstructionVisitor.h:71
Definition Instruction.h:22
Definition Argument.h:13