Skip to content

Commit

Permalink
MLIR: #5 Command Line Flags - Rename files
Browse files Browse the repository at this point in the history
  • Loading branch information
Robertorosmaninho committed Feb 8, 2020
1 parent 63e65ca commit 98df976
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ set(DRV_SRC
driver/exe_path.cpp
driver/targetmachine.cpp
driver/toobj.cpp
driver/tomlir.cpp
driver/tomlirfile.cpp
driver/tool.cpp
driver/archiver.cpp
driver/linker.cpp
Expand All @@ -400,7 +400,7 @@ set(DRV_HDR
driver/linker.h
driver/plugins.h
driver/targetmachine.h
driver/tomlir.cpp
driver/tomlirfile.h
driver/toobj.h
driver/tool.h
)
Expand Down
3 changes: 2 additions & 1 deletion driver/codegenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "driver/cl_options_instrumentation.h"
#include "driver/linker.h"
#include "driver/toobj.h"
#include "driver/tomlir.h"
#include "driver/tomlirfile.h"
#include "gen/dynamiccompile.h"
#include "gen/logger.h"
#include "gen/modules.h"
Expand Down Expand Up @@ -256,6 +256,7 @@ void CodeGenerator::finishLLModule(Module *m) {
insertBitcodeFiles(ir_->module, ir_->context(), global.params.bitcodeFiles);
}

writeMLIRModule(m, mlirContext_, m->objfile.toChars(), ir_);
writeAndFreeLLModule(m->objfile.toChars());
}

Expand Down
1 change: 1 addition & 0 deletions driver/codegenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#pragma once

#include "gen/irstate.h"
#include "mlir/IR/MLIRContext.h"

namespace ldc {

Expand Down
15 changes: 7 additions & 8 deletions driver/tomlir.cpp → driver/tomlirfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Created by Roberto Rosmaninho on 09/10/19.
//

#include "tomlir.h"
#include "tomlirfile.h"

#include "dmd/errors.h"
#include "driver/cl_options.h"
Expand Down Expand Up @@ -38,6 +38,7 @@
#include "llvm/IR/Module.h"
#include <cstddef>
#include <fstream>
#include <mlir/IR/Module.h>

#ifdef LDC_LLVM_SUPPORTED_TARGET_SPIRV
namespace llvm {
Expand All @@ -46,11 +47,13 @@ namespace llvm {
#endif

#include "gen/logger.h"
#include "mlir/IR/Module.h"
#include "dmd/globals.h"
#include "gen/MLIR/MLIRGen.h"
#include "dmd/expression.h"

void writeMLIRModule(Module *m, mlir::MLIRContext &mlirContext,
const char *filename){
const char *filename, IRState *irs){
const auto outputFlags = {global.params.output_o, global.params.output_bc,
global.params.output_ll, global.params.output_s,
global.params.output_mlir};
Expand Down Expand Up @@ -79,15 +82,11 @@ void writeMLIRModule(Module *m, mlir::MLIRContext &mlirContext,
errinfo.message().c_str());
fatal();
}
mlir::OwningModuleRef module = ldc_mlir::mlirGen(mlirContext, m);
mlir::OwningModuleRef module = ldc_mlir::mlirGen(mlirContext, m, irs);
if(!module){
IF_LOG Logger::println("Cannot write MLIR file to '%s'", llpath.c_str());
fatal();
}
module->print(aos);
//AssemblyAnnotator annotator(m->getDataLayout());
//m->print(aos, &annotator);
}


}
}
4 changes: 2 additions & 2 deletions driver/tomlir.h → driver/tomlirfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#ifndef LDC_TOMLIR_H
#define LDC_TOMLIR_H

#include "gen/irstate.h"
#include "dmd/module.h"
#include "mlir/IR/MLIRContext.h"

void writeMLIRModule(Module *m, mlir::MLIRContext &mlirContext,
const char *filename);

const char *filename, IRState *irs);
#endif // LDC_TOMLIR_H

0 comments on commit 98df976

Please sign in to comment.