2021-09-27 14:02:44 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "sir/sir.h"
|
|
|
|
|
2021-10-04 12:10:59 -05:00
|
|
|
namespace codon {
|
2021-09-27 14:02:44 -04:00
|
|
|
namespace ir {
|
|
|
|
namespace util {
|
|
|
|
|
|
|
|
/// Result of an inlining operation.
|
|
|
|
struct InlineResult {
|
|
|
|
/// the result, either a SeriesFlow or FlowInstr
|
|
|
|
Value *result;
|
|
|
|
/// variables added by the inlining
|
|
|
|
std::vector<Var *> newVars;
|
|
|
|
|
|
|
|
operator bool() const { return bool(result); }
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Inline the given function with the supplied arguments.
|
|
|
|
/// @param func the function
|
|
|
|
/// @param args the arguments
|
|
|
|
/// @param callInfo the call information
|
|
|
|
/// @param aggressive true if should inline complex functions
|
|
|
|
/// @return the inlined result, nullptr if unsuccessful
|
|
|
|
InlineResult inlineFunction(Func *func, std::vector<Value *> args,
|
2021-10-04 12:10:59 -05:00
|
|
|
bool aggressive = false, codon::SrcInfo callInfo = {});
|
2021-09-27 14:02:44 -04:00
|
|
|
|
|
|
|
/// Inline the given call.
|
|
|
|
/// @param v the instruction
|
|
|
|
/// @param aggressive true if should inline complex functions
|
|
|
|
/// @return the inlined result, nullptr if unsuccessful
|
|
|
|
InlineResult inlineCall(CallInstr *v, bool aggressive = false);
|
|
|
|
|
|
|
|
} // namespace util
|
|
|
|
} // namespace ir
|
2021-10-04 12:10:59 -05:00
|
|
|
} // namespace codon
|