mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-05-15 18:36:27 +00:00

This reapplies r224503 along with a fix for compiling Fortran by having the clang driver invoke gcc (see r224546, where it was reverted). I have added a testcase for that as well. Original commit message: It is often convenient to use -save-temps to collect the intermediate results of a compilation, e.g., when triaging a bug report. Besides the temporary files for preprocessed source and assembly code, this adds the unoptimized bitcode files as well. This adds a new BackendJobAction, which is mostly mechanical, to run after the CompileJobAction. When not using -save-temps, the BackendJobAction is combined into one job with the CompileJobAction, similar to the way the integrated assembler is handled. I've implemented this entirely as a driver change, so under the hood, it is just using -disable-llvm-optzns to get the unoptimized bitcode. Based in part on a patch by Steven Wu. rdar://problem/18909437 llvm-svn: 224688
153 lines
5.1 KiB
C++
153 lines
5.1 KiB
C++
//===--- Action.cpp - Abstract compilation steps --------------------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "clang/Driver/Action.h"
|
|
#include "llvm/Support/ErrorHandling.h"
|
|
#include <cassert>
|
|
using namespace clang::driver;
|
|
using namespace llvm::opt;
|
|
|
|
Action::~Action() {
|
|
if (OwnsInputs) {
|
|
for (iterator it = begin(), ie = end(); it != ie; ++it)
|
|
delete *it;
|
|
}
|
|
}
|
|
|
|
const char *Action::getClassName(ActionClass AC) {
|
|
switch (AC) {
|
|
case InputClass: return "input";
|
|
case BindArchClass: return "bind-arch";
|
|
case PreprocessJobClass: return "preprocessor";
|
|
case PrecompileJobClass: return "precompiler";
|
|
case AnalyzeJobClass: return "analyzer";
|
|
case MigrateJobClass: return "migrator";
|
|
case CompileJobClass: return "compiler";
|
|
case BackendJobClass: return "backend";
|
|
case AssembleJobClass: return "assembler";
|
|
case LinkJobClass: return "linker";
|
|
case LipoJobClass: return "lipo";
|
|
case DsymutilJobClass: return "dsymutil";
|
|
case VerifyDebugInfoJobClass: return "verify-debug-info";
|
|
case VerifyPCHJobClass: return "verify-pch";
|
|
}
|
|
|
|
llvm_unreachable("invalid class");
|
|
}
|
|
|
|
void InputAction::anchor() {}
|
|
|
|
InputAction::InputAction(const Arg &_Input, types::ID _Type)
|
|
: Action(InputClass, _Type), Input(_Input) {
|
|
}
|
|
|
|
void BindArchAction::anchor() {}
|
|
|
|
BindArchAction::BindArchAction(std::unique_ptr<Action> Input,
|
|
const char *_ArchName)
|
|
: Action(BindArchClass, std::move(Input)), ArchName(_ArchName) {}
|
|
|
|
void JobAction::anchor() {}
|
|
|
|
JobAction::JobAction(ActionClass Kind, std::unique_ptr<Action> Input,
|
|
types::ID Type)
|
|
: Action(Kind, std::move(Input), Type) {}
|
|
|
|
JobAction::JobAction(ActionClass Kind, const ActionList &Inputs, types::ID Type)
|
|
: Action(Kind, Inputs, Type) {
|
|
}
|
|
|
|
void PreprocessJobAction::anchor() {}
|
|
|
|
PreprocessJobAction::PreprocessJobAction(std::unique_ptr<Action> Input,
|
|
types::ID OutputType)
|
|
: JobAction(PreprocessJobClass, std::move(Input), OutputType) {}
|
|
|
|
void PrecompileJobAction::anchor() {}
|
|
|
|
PrecompileJobAction::PrecompileJobAction(std::unique_ptr<Action> Input,
|
|
types::ID OutputType)
|
|
: JobAction(PrecompileJobClass, std::move(Input), OutputType) {}
|
|
|
|
void AnalyzeJobAction::anchor() {}
|
|
|
|
AnalyzeJobAction::AnalyzeJobAction(std::unique_ptr<Action> Input,
|
|
types::ID OutputType)
|
|
: JobAction(AnalyzeJobClass, std::move(Input), OutputType) {}
|
|
|
|
void MigrateJobAction::anchor() {}
|
|
|
|
MigrateJobAction::MigrateJobAction(std::unique_ptr<Action> Input,
|
|
types::ID OutputType)
|
|
: JobAction(MigrateJobClass, std::move(Input), OutputType) {}
|
|
|
|
void CompileJobAction::anchor() {}
|
|
|
|
CompileJobAction::CompileJobAction(std::unique_ptr<Action> Input,
|
|
types::ID OutputType)
|
|
: JobAction(CompileJobClass, std::move(Input), OutputType) {}
|
|
|
|
void BackendJobAction::anchor() {}
|
|
|
|
BackendJobAction::BackendJobAction(std::unique_ptr<Action> Input,
|
|
types::ID OutputType)
|
|
: JobAction(BackendJobClass, std::move(Input), OutputType) {}
|
|
|
|
void AssembleJobAction::anchor() {}
|
|
|
|
AssembleJobAction::AssembleJobAction(std::unique_ptr<Action> Input,
|
|
types::ID OutputType)
|
|
: JobAction(AssembleJobClass, std::move(Input), OutputType) {}
|
|
|
|
void LinkJobAction::anchor() {}
|
|
|
|
LinkJobAction::LinkJobAction(ActionList &Inputs, types::ID Type)
|
|
: JobAction(LinkJobClass, Inputs, Type) {
|
|
}
|
|
|
|
void LipoJobAction::anchor() {}
|
|
|
|
LipoJobAction::LipoJobAction(ActionList &Inputs, types::ID Type)
|
|
: JobAction(LipoJobClass, Inputs, Type) {
|
|
}
|
|
|
|
void DsymutilJobAction::anchor() {}
|
|
|
|
DsymutilJobAction::DsymutilJobAction(ActionList &Inputs, types::ID Type)
|
|
: JobAction(DsymutilJobClass, Inputs, Type) {
|
|
}
|
|
|
|
void VerifyJobAction::anchor() {}
|
|
|
|
VerifyJobAction::VerifyJobAction(ActionClass Kind,
|
|
std::unique_ptr<Action> Input, types::ID Type)
|
|
: JobAction(Kind, std::move(Input), Type) {
|
|
assert((Kind == VerifyDebugInfoJobClass || Kind == VerifyPCHJobClass) &&
|
|
"ActionClass is not a valid VerifyJobAction");
|
|
}
|
|
|
|
VerifyJobAction::VerifyJobAction(ActionClass Kind, ActionList &Inputs,
|
|
types::ID Type)
|
|
: JobAction(Kind, Inputs, Type) {
|
|
assert((Kind == VerifyDebugInfoJobClass || Kind == VerifyPCHJobClass) &&
|
|
"ActionClass is not a valid VerifyJobAction");
|
|
}
|
|
|
|
void VerifyDebugInfoJobAction::anchor() {}
|
|
|
|
VerifyDebugInfoJobAction::VerifyDebugInfoJobAction(
|
|
std::unique_ptr<Action> Input, types::ID Type)
|
|
: VerifyJobAction(VerifyDebugInfoJobClass, std::move(Input), Type) {}
|
|
|
|
void VerifyPCHJobAction::anchor() {}
|
|
|
|
VerifyPCHJobAction::VerifyPCHJobAction(std::unique_ptr<Action> Input,
|
|
types::ID Type)
|
|
: VerifyJobAction(VerifyPCHJobClass, std::move(Input), Type) {}
|