Skip to content

Commit

Permalink
MLIR: #7 Command Line Flags - Fix typos, delete unnecessary includes
Browse files Browse the repository at this point in the history
  • Loading branch information
Robertorosmaninho committed Feb 12, 2020
1 parent b4b0a68 commit 10d760b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 53 deletions.
12 changes: 10 additions & 2 deletions driver/codegenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,20 @@
#pragma once

#include "gen/irstate.h"
#if LDC_MLIR_ENABLED
#include "mlir/IR/MLIRContext.h"
#endif

namespace ldc {

class CodeGenerator {
public:
CodeGenerator(llvm::LLVMContext &context, mlir::MLIRContext &mlirContext,
bool singleObj);
CodeGenerator(llvm::LLVMContext &context,
#if LDC_MLIR_ENABLED
mlir::MLIRContext &mlirContext,
#endif
bool singleObj);

~CodeGenerator();
void emit(Module *m);

Expand All @@ -37,7 +43,9 @@ class CodeGenerator {
void writeAndFreeLLModule(const char *filename);

llvm::LLVMContext &context_;
#if LDC_MLIR_ENABLED
mlir::MLIRContext &mlirContext_;
#endif
int moduleCount_;
bool const singleObj_;
IRState *ir_;
Expand Down
1 change: 0 additions & 1 deletion driver/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ void gendocfile(Module *m);
void generateJson(Modules *modules);

using namespace opts;
using namespace ldc_mlir;

static StringsAdapter impPathsStore("I", global.params.imppath);
static cl::list<std::string, StringsAdapter>
Expand Down
51 changes: 2 additions & 49 deletions driver/tomlirfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,54 +10,7 @@
#if LDC_MLIR_ENABLED

#include "tomlirfile.h"

#include "dmd/errors.h"
#include "driver/cl_options.h"
#include "driver/cache.h"
#include "driver/targetmachine.h"
#include "driver/tool.h"
#include "gen/irstate.h"
#include "gen/logger.h"
#include "gen/optimizer.h"
#include "llvm/IR/AssemblyAnnotationWriter.h"
#include "llvm/IR/Verifier.h"
#include "llvm/Analysis/ModuleSummaryAnalysis.h"
#if LDC_LLVM_VER >= 400
#include "llvm/Analysis/ProfileSummaryInfo.h"
#include "llvm/Bitcode/BitcodeWriter.h"
#else
#include "llvm/Bitcode/ReaderWriter.h"
#endif
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/Program.h"
#include "llvm/Support/Path.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#if LDC_LLVM_VER >= 600
#include "llvm/CodeGen/TargetSubtargetInfo.h"
#else
#include "llvm/Target/TargetSubtargetInfo.h"
#endif
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/IR/Module.h"
#include <cstddef>
#include <fstream>
#include <mlir/IR/Module.h>

#ifdef LDC_LLVM_SUPPORTED_TARGET_SPIRV
namespace llvm {
ModulePass *createSPIRVWriterPass(llvm::raw_ostream &Str);
}
#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, IRState *irs){
Expand All @@ -81,11 +34,11 @@ void writeMLIRModule(Module *m, mlir::MLIRContext &mlirContext,
//Write MLIR
if(global.params.output_mlir) {
const auto llpath = replaceExtensionWith(global.mlir_ext);
Logger::println("Writting MLIR to %s\n", llpath.c_str());
Logger::println("Writing MLIR to %s\n", llpath.c_str());
std::error_code errinfo;
llvm::raw_fd_ostream aos(llpath, errinfo, llvm::sys::fs::F_None);
if(aos.has_error()){
error(Loc(), "Cannot write MLIR file '%s':%s", llpath.c_str(),
error(Loc(), "Cannot write MLIR file '%s': %s", llpath.c_str(),
errinfo.message().c_str());
fatal();
}
Expand Down
2 changes: 1 addition & 1 deletion driver/tomlirfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
//
// Handles emission of "finished" MLIR modules to on-disk object files.
// Handles emission of MLIR modules to on-disk object files.
//
//===----------------------------------------------------------------------===//

Expand Down

0 comments on commit 10d760b

Please sign in to comment.