Skip to content

Commit

Permalink
rewriter: add --enable-dav1d_get_picture-post-condition option, on …
Browse files Browse the repository at this point in the history
…by default

We still want to be able to run the rewriter on `dav1d`
normally without post conditions while this is still a WIP.
Or on Arm, where IA2 still lacks support for post conditions.
  • Loading branch information
kkysen committed Dec 18, 2024
1 parent 0a64bd9 commit b331294
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tools/rewriter/GenCallAsm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1053,9 +1053,10 @@ std::string emit_asm_wrapper(AbiSignature &sig,
// The name is `${target_name}_post_condition`,
// and we only do this for `dav1d_get_picture`.
std::optional<std::string> target_post_condition_name = std::nullopt;
if (target_name && *target_name == "dav1d_get_picture") {
if (enable_dav1d_get_picture_post_condition && target_name && *target_name == "dav1d_get_picture") {
target_post_condition_name = *target_name + "_post_condition";
}

if (target_post_condition_name) {
emit_post_condition_fn_call(aw, arch, *target_post_condition_name);
}
Expand Down
2 changes: 2 additions & 0 deletions tools/rewriter/GenCallAsm.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ enum class Arch {
Aarch64, X86
};

extern bool enable_dav1d_get_picture_post_condition;

// Generates a wrapper for a function named \p name with the signature \p sig.
// The WrapperKind parameter \p kind determines the type of call which may
// affect the order of operations and the layout of the wrapper stack frame.
Expand Down
8 changes: 8 additions & 0 deletions tools/rewriter/SourceRewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,17 @@ static llvm::cl::opt<std::string>
llvm::cl::cat(SourceRewriterCategory),
llvm::cl::desc("<prefix for output files>"));

static llvm::cl::opt<bool>
EnableDav1dGetPicturePostCondition("enable-dav1d_get_picture-post-condition",
llvm::cl::init(true),
llvm::cl::cat(SourceRewriterCategory),
llvm::cl::desc("enable calling the post condition function hardcoded for dav1d_get_picture"));

static Arch Target;
static std::string RootDirectory;
static std::string OutputDirectory;
static std::string OutputPrefix;
bool enable_dav1d_get_picture_post_condition = true;

// Map each translation unit's filename to its pkey.
static std::map<Filename, Pkey> file_pkeys;
Expand Down Expand Up @@ -1098,6 +1105,7 @@ int main(int argc, const char **argv) {
RootDirectory = RootDirectoryOption;
OutputDirectory = OutputDirectoryOption;
OutputPrefix = OutputPrefixOption;
enable_dav1d_get_picture_post_condition = EnableDav1dGetPicturePostCondition;

RefactoringTool tool(options_parser.getCompilations(),
options_parser.getSourcePathList());
Expand Down

0 comments on commit b331294

Please sign in to comment.