524fdc13a9
This is a reland of b71d2d9996
Original change's description:
> [llvm] Add initial scaffolding
>
> This change adds the gclient and GN changes needed to build
> an executable using LLVM in the Dart tree as well as a basic
> testing framework based on llvm-lit.
>
> Change-Id: I9009a98ff95043cc3754966f31697ba7f1712310
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106434
> Commit-Queue: Jake Ehrlich <jakehehrlich@google.com>
> Reviewed-by: Alexander Thomas <athom@google.com>
> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Change-Id: Ib3cd3299ed463133616c666285f9a58fa387b5bd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/107829
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Jake Ehrlich <jakehehrlich@google.com>
43 lines
1.0 KiB
C++
43 lines
1.0 KiB
C++
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
#include <memory>
|
|
|
|
#include "llvm/ADT/StringRef.h"
|
|
#include "llvm/IR/LLVMContext.h"
|
|
#include "llvm/IR/Module.h"
|
|
#include "llvm/IRReader/IRReader.h"
|
|
#include "llvm/Support/InitLLVM.h"
|
|
#include "llvm/Support/SourceMgr.h"
|
|
#include "llvm/Support/WithColor.h"
|
|
|
|
using namespace llvm;
|
|
|
|
namespace {
|
|
|
|
StringRef tool_name;
|
|
|
|
LLVM_ATTRIBUTE_NORETURN void error(Twine message) {
|
|
WithColor::error(errs(), "llvm-codegen") << message << ".\n";
|
|
errs().flush();
|
|
exit(1);
|
|
}
|
|
|
|
} // namespace
|
|
|
|
int main(int argc, char** argv) {
|
|
InitLLVM X(argc, argv);
|
|
|
|
LLVMContext context;
|
|
SMDiagnostic err;
|
|
if (argc != 2) error("exactly one argument is taken");
|
|
tool_name = argv[0];
|
|
std::unique_ptr<Module> mod = parseIRFile(argv[1], err, context);
|
|
if (mod == nullptr) {
|
|
err.print(tool_name.data(), errs());
|
|
exit(1);
|
|
}
|
|
mod->print(outs(), nullptr);
|
|
}
|