-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lldb] add architecture depended IR passes
Function calls support in LLDB expressions for RISCV: 4 of 5 Adds architecture depended IR passes handler, that can apply architecture specific IR passes before IRForTarget.
- Loading branch information
Showing
6 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
lldb/source/Plugins/Architecture/RISCV/ArchitectureRISCV.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
//===-- ArchitectureRISCV.cpp----------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "Plugins/Architecture/RISCV/ArchitectureRISCV.h" | ||
#include "lldb/Core/PluginManager.h" | ||
#include "lldb/Target/RegisterContext.h" | ||
#include "lldb/Target/Thread.h" | ||
#include "lldb/Utility/ArchSpec.h" | ||
|
||
#include "llvm/IR/LegacyPassManager.h" | ||
|
||
#include "DirectToIndirectFCR.h" | ||
|
||
using namespace lldb_private; | ||
using namespace lldb; | ||
|
||
LLDB_PLUGIN_DEFINE(ArchitectureRISCV) | ||
|
||
void ArchitectureRISCV::Initialize() { | ||
PluginManager::RegisterPlugin(GetPluginNameStatic(), | ||
"RISCV-specific algorithms", | ||
&ArchitectureRISCV::Create); | ||
} | ||
|
||
void ArchitectureRISCV::Terminate() { | ||
PluginManager::UnregisterPlugin(&ArchitectureRISCV::Create); | ||
} | ||
|
||
std::unique_ptr<Architecture> ArchitectureRISCV::Create(const ArchSpec &arch) { | ||
if (!arch.GetTriple().isRISCV()) | ||
return nullptr; | ||
return std::unique_ptr<Architecture>(new ArchitectureRISCV()); | ||
} | ||
|
||
void ArchitectureRISCV::OverrideStopInfo(Thread &thread) const {} | ||
|
||
std::unique_ptr<llvm::legacy::PassManager> | ||
ArchitectureRISCV::GetArchitectureCustomPasses( | ||
const ExecutionContext &exe_ctx, const llvm::StringRef expr) const { | ||
// LLDB generates additional support functions like | ||
// '_$__lldb_valid_pointer_check', that do not require custom passes | ||
if (expr != "$__lldb_expr") | ||
return nullptr; | ||
|
||
std::unique_ptr<llvm::legacy::PassManager> custom_passes = | ||
std::make_unique<llvm::legacy::PassManager>(); | ||
auto *P = createDirectToIndirectFCR(exe_ctx); | ||
custom_passes->add(P); | ||
return custom_passes; | ||
} |
34 changes: 34 additions & 0 deletions
34
lldb/source/Plugins/Architecture/RISCV/ArchitectureRISCV.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
//===-- ArchitectureRISCV.h -------------------------------------*- C++ -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#pragma once | ||
|
||
#include "lldb/Core/Architecture.h" | ||
|
||
namespace lldb_private { | ||
|
||
class ArchitectureRISCV : public Architecture { | ||
public: | ||
static llvm::StringRef GetPluginNameStatic() { return "riscv"; } | ||
static void Initialize(); | ||
static void Terminate(); | ||
|
||
llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); } | ||
|
||
void OverrideStopInfo(Thread &thread) const override; | ||
|
||
std::unique_ptr<llvm::legacy::PassManager> | ||
GetArchitectureCustomPasses(const ExecutionContext &exe_ctx, | ||
const llvm::StringRef expr) const override; | ||
|
||
private: | ||
static std::unique_ptr<Architecture> Create(const ArchSpec &arch); | ||
ArchitectureRISCV() = default; | ||
}; | ||
|
||
} // namespace lldb_private |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
add_lldb_library(lldbPluginArchitectureRISCV PLUGIN | ||
ArchitectureRISCV.cpp | ||
DirectToIndirectFCR.cpp | ||
|
||
LINK_LIBS | ||
lldbPluginProcessUtility | ||
lldbCore | ||
lldbTarget | ||
lldbUtility | ||
LINK_COMPONENTS | ||
Support | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters