Skip to content

Commit

Permalink
chore(compiler): make clang-format happy
Browse files Browse the repository at this point in the history
  • Loading branch information
aPere3 committed Feb 7, 2025
1 parent 6512efd commit 9d2ed5a
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,6 @@ enum class Target {

class CompilerEngine {
public:



CompilerEngine(std::shared_ptr<CompilationContext> compilationContext)
: overrideMaxEintPrecision(), overrideMaxMANP(), compilerOptions(),
generateProgramInfo(true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,8 @@ std::string roundTrip(const char *module) {
std::string backingString;
llvm::raw_string_ostream os(backingString);

llvm::Expected<mlir::concretelang::CompilationResult>
retOrErr = ce.compile(
module, mlir::concretelang::Target::ROUND_TRIP);
llvm::Expected<mlir::concretelang::CompilationResult> retOrErr =
ce.compile(module, mlir::concretelang::Target::ROUND_TRIP);
if (!retOrErr) {
os << "MLIR parsing failed: " << llvm::toString(retOrErr.takeError());
throw std::runtime_error(os.str());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using concretelang::protocol::Message;



namespace mlir {
namespace concretelang {

Expand Down
41 changes: 17 additions & 24 deletions compilers/concrete-compiler/compiler/lib/Support/CompilerEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,18 @@ namespace {
/// Returns the path of the shared library
std::string getSharedLibraryPath(std::string outputDirPath) {
llvm::SmallString<0> sharedLibraryPath(outputDirPath);
llvm::sys::path::append(
sharedLibraryPath,
"sharedlib" +
mlir::concretelang::Library::DOT_SHARED_LIB_EXT);
llvm::sys::path::append(sharedLibraryPath,
"sharedlib" +
mlir::concretelang::Library::DOT_SHARED_LIB_EXT);
return sharedLibraryPath.str().str();
}

/// Returns the path of the static library
std::string getStaticLibraryPath(std::string outputDirPath) {
llvm::SmallString<0> staticLibraryPath(outputDirPath);
llvm::sys::path::append(
staticLibraryPath,
"staticlib" +
mlir::concretelang::Library::DOT_STATIC_LIB_EXT);
llvm::sys::path::append(staticLibraryPath,
"staticlib" +
mlir::concretelang::Library::DOT_STATIC_LIB_EXT);
return staticLibraryPath.str().str();
}

Expand Down Expand Up @@ -286,8 +284,8 @@ CompilerEngine::compile(llvm::SourceMgr &sm, Target target, OptionalLib lib) {
std::unique_ptr<mlir::SourceMgrDiagnosticVerifierHandler> smHandler;
std::string diagnosticsMsg;
llvm::raw_string_ostream diagnosticsOS(diagnosticsMsg);
auto errorDiag = [&](std::string prefixMsg)
-> llvm::Expected<CompilationResult> {
auto errorDiag =
[&](std::string prefixMsg) -> llvm::Expected<CompilationResult> {
return StreamStringError(prefixMsg + "\n" + diagnosticsOS.str());
};

Expand Down Expand Up @@ -848,8 +846,7 @@ void Library::addExtraObjectFilePath(std::string path) {
objectsPath.push_back(path);
}

Result<Message<concreteprotocol::ProgramInfo>>
Library::getProgramInfo() {
Result<Message<concreteprotocol::ProgramInfo>> Library::getProgramInfo() {
if (!programInfo.has_value()) {
programInfo = Message<concreteprotocol::ProgramInfo>();
auto path = this->getProgramInfoPath();
Expand All @@ -866,9 +863,7 @@ Library::getProgramInfo() {
return programInfo.value();
}

const std::string &Library::getOutputDirPath() const {
return outputDirPath;
}
const std::string &Library::getOutputDirPath() const { return outputDirPath; }

/// Returns the path of the shared library
std::string Library::getSharedLibraryPath() const {
Expand Down Expand Up @@ -905,8 +900,7 @@ llvm::Expected<std::string> Library::emitProgramInfoJSON() {
return programInfoPath;
}

llvm::Expected<std::string>
Library::emitCompilationFeedbackJSON() {
llvm::Expected<std::string> Library::emitCompilationFeedbackJSON() {
auto path = ::getCompilationFeedbackPath(outputDirPath);
llvm::json::Value value(compilationFeedback);
std::error_code error;
Expand Down Expand Up @@ -976,9 +970,9 @@ std::string ensureLibDotExt(std::string path, std::string dotExt) {
return path + dotExt;
}

llvm::Expected<std::string> Library::emit(
std::string path, std::string dotExt, std::string linker,
std::optional<std::vector<std::string>> extraArgs) {
llvm::Expected<std::string>
Library::emit(std::string path, std::string dotExt, std::string linker,
std::optional<std::vector<std::string>> extraArgs) {
auto pathDotExt = ensureLibDotExt(path, dotExt);
auto error = mlir::concretelang::emitLibrary(objectsPath, pathDotExt, linker,
extraArgs);
Expand Down Expand Up @@ -1069,10 +1063,9 @@ llvm::Expected<std::string> Library::emitStatic() {
return path;
}

llvm::Error Library::emitArtifacts(bool sharedLib,
bool staticLib,
bool clientParameters,
bool compilationFeedback) {
llvm::Error Library::emitArtifacts(bool sharedLib, bool staticLib,
bool clientParameters,
bool compilationFeedback) {
// Create output directory if doesn't exist
llvm::sys::fs::create_directory(outputDirPath);
if (sharedLib) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,13 @@ generateGate(mlir::Type inputType,
auto plaintextGateInfo = output.asBuilder().initTypeInfo().initPlaintext();
plaintextGateInfo.setShape(inputShape);
plaintextGateInfo.setIntegerPrecision(
getCorrespondingPrecision(
inputType.getIntOrFloatBitWidth()));
getCorrespondingPrecision(inputType.getIntOrFloatBitWidth()));
plaintextGateInfo.setIsSigned(inputType.isSignedInteger());

auto rawInfo = output.asBuilder().initRawInfo();
rawInfo.setShape(inputShape);
rawInfo.setIntegerPrecision(
getCorrespondingPrecision(
inputType.getIntOrFloatBitWidth()));
getCorrespondingPrecision(inputType.getIntOrFloatBitWidth()));
rawInfo.setIsSigned(inputType.isSignedInteger());
} else if (inputEncoding.hasIndex()) {
// TODO - The index type is dependant of the target architecture,
Expand Down
11 changes: 6 additions & 5 deletions compilers/concrete-compiler/compiler/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,11 +544,12 @@ cmdlineCompilationOptions() {
/// requested transformations succeeded.
///
/// Compilation output is written to the stream specified by `os`.
mlir::LogicalResult processInputBuffer(
std::unique_ptr<llvm::MemoryBuffer> buffer, std::string sourceFileName,
mlir::concretelang::CompilationOptions &options, enum Action action,
llvm::raw_ostream &os,
std::shared_ptr<mlir::concretelang::Library> outputLib) {
mlir::LogicalResult
processInputBuffer(std::unique_ptr<llvm::MemoryBuffer> buffer,
std::string sourceFileName,
mlir::concretelang::CompilationOptions &options,
enum Action action, llvm::raw_ostream &os,
std::shared_ptr<mlir::concretelang::Library> outputLib) {
std::shared_ptr<mlir::concretelang::CompilationContext> ccx =
mlir::concretelang::CompilationContext::createShared();

Expand Down

0 comments on commit 9d2ed5a

Please sign in to comment.