#pragma once

#include "../Pass.h"

namespace sysy {

class LargeArrayToGlobalPass : public OptimizationPass {
public:
    static void *ID;

    LargeArrayToGlobalPass() : OptimizationPass("LargeArrayToGlobal", Granularity::Module) {}

    bool runOnModule(Module *M, AnalysisManager &AM) override;
    void *getPassID() const override {
        return &ID;
    }

private:
    unsigned calculateTypeSize(Type *type);
    void convertAllocaToGlobal(AllocaInst *alloca, Function *F, Module *M);
    std::string generateUniqueGlobalName(AllocaInst *alloca, Function *F);
};

} // namespace sysy