Add the overview section to the videos doc

This commit is contained in:
Sameer Rahmani 2021-07-10 17:52:53 +01:00
parent afa2310b02
commit 9102085d83
7 changed files with 977 additions and 8 deletions

View File

@ -21,6 +21,14 @@ target_link_libraries(serenec PRIVATE
MLIRSideEffectInterfaces
MLIRTransforms
LLVMX86AsmParser
LLVMOption
#clangTooling
clangDriver
clangBasic
clangdSupport
clangFrontend
clangEdit
clangLex
)

View File

@ -32,9 +32,14 @@
#include "serene/slir/generatable.h"
#include "serene/slir/slir.h"
#include <clang/Driver/Compilation.h>
#include <clang/Driver/Driver.h>
#include <clang/Frontend/TextDiagnosticPrinter.h>
#include <clang/Tooling/Tooling.h>
#include <llvm/IR/LegacyPassManager.h>
#include <llvm/Support/CommandLine.h>
#include <llvm/Support/FileSystem.h>
#include <llvm/Support/FormatVariadic.h>
#include <llvm/Support/Host.h>
#include <llvm/Support/TargetRegistry.h>
#include <llvm/Support/TargetSelect.h>
@ -137,10 +142,11 @@ int dumpAsObject(Namespace &ns) {
module.setDataLayout(targetMachine->createDataLayout());
auto filename =
strcmp(outputFile.c_str(), "-") == 0 ? "output.o" : outputFile.c_str();
strcmp(outputFile.c_str(), "-") == 0 ? "output" : outputFile.c_str();
std::error_code ec;
llvm::raw_fd_ostream dest(filename, ec, llvm::sys::fs::OF_None);
llvm::raw_fd_ostream dest(llvm::formatv("{0}.o", filename).str(), ec,
llvm::sys::fs::OF_None);
if (ec) {
llvm::errs() << "Could not open file: " << ec.message();
@ -160,6 +166,48 @@ int dumpAsObject(Namespace &ns) {
llvm::outs() << "Wrote " << filename << "\n";
clang::IntrusiveRefCntPtr<clang::DiagnosticIDs> diagID(
new clang::DiagnosticIDs());
clang::IntrusiveRefCntPtr<clang::DiagnosticOptions> diagOpts =
new clang::DiagnosticOptions();
clang::TextDiagnosticPrinter diagPrinter(llvm::errs(), &*diagOpts);
clang::DiagnosticsEngine diags(diagID, &*diagOpts, &diagPrinter);
clang::driver::Driver d("clang", targetTriple, diags, "Serene compiler");
std::vector<const char *> args;
args.push_back(filename);
args.push_back("-o");
args.push_back(
llvm::formatv("/home/lxsameer/src/serene/serene/build/{0}.o", filename)
.str()
.c_str());
d.setCheckInputsExist(false);
const std::unique_ptr<clang::driver::Compilation> compilation(
d.BuildCompilation(args));
if (!compilation) {
return 1;
}
llvm::SmallVector<std::pair<int, const clang::driver::Command *>> failCommand;
// compilation->ExecuteJobs(compilation->getJobs(), failCommand);
d.ExecuteCompilation(*compilation, failCommand);
if (failCommand.empty()) {
llvm::outs() << "Done!\n";
} else {
llvm::errs() << "Linking failed!\n";
}
// const llvm::opt::ArgStringList *const cc1Args = n
// getCC1Arguments(&diags, compilation.get());
// if (!cc1Args)
// return 2;
// std::unique_ptr<clang::CompilerInvocation> Invocation(
// clang::tooling::newInvocation(&diags, *cc1Args, "hnt"));
// return clang::tooling::runInvocation("hnt", compilation.get(),
// std::move(Invocation),
// std::move(PCHContainerOps));
return 0;
};

View File

@ -14,7 +14,7 @@ fi
export CC
export CXX
export CCACHE_SLOPPINESS="pch_defines,time_macros"
# Meke sure to use `lld` linker it faster and has a better UX
export LDFLAGS="-fuse-ld=lld"
export ASAN_FLAG="-fsanitize=address"

496
docs/imgs/llvm_dia.svg Normal file
View File

@ -0,0 +1,496 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="300mm"
height="121mm"
viewBox="0 0 299.99999 121"
version="1.1"
id="svg8"
inkscape:version="1.0.2 (e86c870879, 2021-01-15)"
sodipodi:docname="mlir.svg"
inkscape:export-filename="/home/lxsameer/llvm.png"
inkscape:export-xdpi="92.360001"
inkscape:export-ydpi="92.360001">
<defs
id="defs2">
<marker
style="overflow:visible"
id="marker1383"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow1Lstart"
inkscape:isstock="true">
<path
transform="matrix(0.8,0,0,0.8,10,0)"
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt"
d="M 0,0 5,-5 -12.5,0 5,5 Z"
id="path1381" />
</marker>
<marker
style="overflow:visible"
id="marker1361"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow1Lstart"
inkscape:isstock="true">
<path
transform="matrix(0.8,0,0,0.8,10,0)"
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt"
d="M 0,0 5,-5 -12.5,0 5,5 Z"
id="path1359" />
</marker>
<marker
style="overflow:visible"
id="marker1345"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow1Lstart"
inkscape:isstock="true">
<path
transform="matrix(0.8,0,0,0.8,10,0)"
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt"
d="M 0,0 5,-5 -12.5,0 5,5 Z"
id="path1343" />
</marker>
<marker
style="overflow:visible"
id="Arrow1Lstart"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow1Lstart"
inkscape:isstock="true">
<path
transform="matrix(0.8,0,0,0.8,10,0)"
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt"
d="M 0,0 5,-5 -12.5,0 5,5 Z"
id="path1073" />
</marker>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#2f2f2f"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="1"
inkscape:pageshadow="2"
inkscape:zoom="0.98994949"
inkscape:cx="294.03577"
inkscape:cy="132.14784"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
inkscape:document-rotation="0"
showgrid="false"
showguides="true"
inkscape:guide-bbox="true"
inkscape:window-width="1920"
inkscape:window-height="1064"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="0"
inkscape:pagecheckerboard="false"
units="mm"
scale-x="1" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<rect
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0.680398;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect833"
width="53.203156"
height="99.187119"
x="39.798038"
y="14.766902" />
<rect
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0.680398;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect845"
width="53.203156"
height="99.187119"
x="204.01189"
y="14.766902" />
<rect
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0.680398;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect847"
width="53.203156"
height="99.187119"
x="121.1113"
y="14.766902" />
<rect
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0.904656;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect853"
width="32.496605"
height="11.482824"
x="50.151314"
y="25.091484" />
<rect
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0.904656;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect855"
width="32.496605"
height="11.482824"
x="49.647457"
y="46.382851" />
<rect
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0.904656;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect857"
width="32.496605"
height="11.482824"
x="48.86647"
y="88.965683" />
<rect
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0.904656;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect859"
width="32.496605"
height="11.482824"
x="50.000584"
y="67.674217" />
<rect
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0.904656;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect877"
width="32.496605"
height="11.482824"
x="215.36081"
y="26.682007" />
<rect
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0.904656;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect879"
width="32.496605"
height="11.482824"
x="214.85695"
y="47.973373" />
<rect
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0.904656;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect881"
width="32.496605"
height="11.482824"
x="214.07596"
y="90.556221" />
<rect
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0.904656;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect883"
width="32.496605"
height="11.482824"
x="215.21007"
y="69.264763" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.230399px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 19.103878,30.432169 31.048358,0.08648"
id="path893"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.230399px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 19.208101,51.519017 30.441484,0.12621"
id="path895"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.230399px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 19.207508,72.830702 30.795797,-0.02086"
id="path897"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.230399px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 19.639113,93.83918 48.872908,93.727557"
id="path899"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.230399px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 80.324067,36.574308 121.1113,53.391941"
id="path901"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
inkscape:connection-start="#rect853"
inkscape:connection-end="#rect847" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.230399px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 82.144062,54.554286 121.1113,60.382049"
id="path903"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
inkscape:connection-start="#rect855"
inkscape:connection-end="#rect847" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.230399px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 82.497189,71.609542 121.1113,67.317372"
id="path905"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
inkscape:connection-start="#rect859"
inkscape:connection-end="#rect847" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.230399px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 80.741868,88.965683 121.1113,74.13391"
id="path907"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
inkscape:connection-start="#rect857"
inkscape:connection-end="#rect847" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.230399px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 174.31445,60.964566 40.5425,-5.17556"
id="path935"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
inkscape:connection-start="#rect847"
inkscape:connection-end="#rect879" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.230399px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 174.31445,67.74205 40.89562,5.198643"
id="path937"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
inkscape:connection-start="#rect847"
inkscape:connection-end="#rect883" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.230399px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 174.31445,74.644506 41.15859,15.911715"
id="path939"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
inkscape:connection-start="#rect847"
inkscape:connection-end="#rect881" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.230399px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 174.31445,54.233956 42.2124,-16.069125"
id="path941"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
inkscape:connection-start="#rect847"
inkscape:connection-end="#rect877" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.230399px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 257.21439,63.923698 17.00337,0.0079"
id="path947"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0" />
<text
xml:space="preserve"
style="font-size:9.21593px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.230399;fill:#f9f9f9;"
x="125.76978"
y="66.61837"
id="text951"><tspan
sodipodi:role="line"
id="tspan949"
x="125.76978"
y="66.61837"
style="stroke-width:0.230399;fill:#f9f9f9;">Optimizers</tspan></text>
<text
xml:space="preserve"
style="font-size:6.14398px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.230399;fill:#f9f9f9;"
x="58.58448"
y="32.424187"
id="text955"><tspan
sodipodi:role="line"
id="tspan953"
x="58.58448"
y="32.424187"
style="font-size:6.14398px;stroke-width:0.230399;fill:#f9f9f9;">Clang</tspan></text>
<text
xml:space="preserve"
style="font-size:6.14398px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.230399;fill:#f9f9f9;"
x="59.840881"
y="54.154854"
id="text959"><tspan
sodipodi:role="line"
id="tspan957"
x="59.840881"
y="54.154854"
style="font-size:6.14398px;stroke-width:0.230399;fill:#f9f9f9;">Rust</tspan></text>
<text
xml:space="preserve"
style="font-size:6.14398px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.230399;fill:#f9f9f9;"
x="56.326378"
y="75.648979"
id="text963"><tspan
sodipodi:role="line"
id="tspan961"
x="56.326378"
y="75.648979"
style="font-size:6.14398px;stroke-width:0.230399;fill:#f9f9f9;">Haskell</tspan></text>
<text
xml:space="preserve"
style="font-size:6.14398px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.230399;fill:#f9f9f9;"
x="55.91111"
y="96.768547"
id="text967"><tspan
sodipodi:role="line"
id="tspan965"
x="55.91111"
y="96.768547"
style="font-size:6.14398px;stroke-width:0.230399;fill:#f9f9f9;">Serene</tspan></text>
<text
xml:space="preserve"
style="font-size:9.21593px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.230399;fill:#f9f9f9;"
x="48.082981"
y="11.066843"
id="text971"><tspan
sodipodi:role="line"
id="tspan969"
x="48.082981"
y="11.066843"
style="stroke-width:0.230399;fill:#f9f9f9;">Frontend</tspan></text>
<text
xml:space="preserve"
style="font-size:9.21593px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.230399;fill:#f9f9f9;"
x="213.57785"
y="10.725649"
id="text975"><tspan
sodipodi:role="line"
id="tspan973"
x="213.57785"
y="10.725649"
style="stroke-width:0.230399;fill:#f9f9f9;">Backend</tspan></text>
<text
xml:space="preserve"
style="font-size:6.14398px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.230399;fill:#f9f9f9;"
x="224.12849"
y="34.484726"
id="text981"><tspan
sodipodi:role="line"
id="tspan979"
x="224.12849"
y="34.484726"
style="font-size:6.14398px;stroke-width:0.230399;fill:#f9f9f9;">ARM</tspan></text>
<text
xml:space="preserve"
style="font-size:6.14398px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.230399;fill:#f9f9f9;"
x="225.47711"
y="55.859039"
id="text985"><tspan
sodipodi:role="line"
id="tspan983"
x="225.47711"
y="55.859039"
style="font-size:6.14398px;stroke-width:0.230399;fill:#f9f9f9;">X86</tspan></text>
<text
xml:space="preserve"
style="font-size:6.14398px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.230399;fill:#f9f9f9;"
x="225.302"
y="77.067497"
id="text989"><tspan
sodipodi:role="line"
id="tspan987"
x="225.302"
y="77.067497"
style="font-size:6.14398px;stroke-width:0.230399;fill:#f9f9f9;">PPC</tspan></text>
<text
xml:space="preserve"
style="font-size:6.14398px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.230399;fill:#f9f9f9;"
x="225.76587"
y="98.383621"
id="text993"><tspan
sodipodi:role="line"
id="tspan991"
x="225.76587"
y="98.383621"
style="font-size:6.14398px;stroke-width:0.230399;fill:#f9f9f9;">WA</tspan></text>
<text
xml:space="preserve"
style="font-size:6.14398px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.230399;fill:#f9f9f9;"
x="1.8287945"
y="26.920044"
id="text997"><tspan
sodipodi:role="line"
id="tspan995"
x="1.8287945"
y="26.920044"
style="font-size:6.14398px;stroke-width:0.230399;fill:#f9f9f9;">Source Code</tspan></text>
<text
xml:space="preserve"
style="font-size:6.14398px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.230399;fill:#f9f9f9;"
x="1.8287945"
y="47.655968"
id="text1001"><tspan
sodipodi:role="line"
id="tspan999"
x="1.8287945"
y="47.655968"
style="font-size:6.14398px;stroke-width:0.230399;fill:#f9f9f9;">Source Code</tspan></text>
<text
xml:space="preserve"
style="font-size:6.14398px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.230399;fill:#f9f9f9;"
x="1.8287945"
y="68.852684"
id="text1005"><tspan
sodipodi:role="line"
id="tspan1003"
x="1.8287945"
y="68.852684"
style="font-size:6.14398px;stroke-width:0.230399;fill:#f9f9f9;">Source Code</tspan></text>
<text
xml:space="preserve"
style="font-size:6.14398px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.230399;fill:#f9f9f9;"
x="1.8287945"
y="90.049477"
id="text1009"><tspan
sodipodi:role="line"
id="tspan1007"
x="1.8287945"
y="90.049477"
style="font-size:6.14398px;stroke-width:0.230399;fill:#f9f9f9;">Source Code</tspan></text>
<text
xml:space="preserve"
style="font-size:6.14398px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.230399;fill:#f9f9f9;"
x="260.26126"
y="61.178581"
id="text1013"><tspan
sodipodi:role="line"
id="tspan1011"
x="260.26126"
y="61.178581"
style="font-size:6.14398px;stroke-width:0.230399;fill:#f9f9f9;">Machine Code</tspan></text>
<text
xml:space="preserve"
style="font-size:5.64444px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.264583;fill:#f9f9f9;"
x="59.464577"
y="117.82257"
id="text1469"
transform="rotate(-20.430611)"><tspan
sodipodi:role="line"
id="tspan1467"
x="59.464577"
y="117.82257"
style="font-size:5.64444px;stroke-width:0.264583;fill:#f9f9f9;">LLVM IR</tspan></text>
<text
xml:space="preserve"
style="font-size:5.64444px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.264583;fill:#f9f9f9;"
x="197.69336"
y="11.637094"
id="text1473"
transform="rotate(21.686113)"
inkscape:transform-center-x="0.58506171"
inkscape:transform-center-y="-0.021176311"><tspan
sodipodi:role="line"
id="tspan1471"
x="197.69336"
y="11.637094"
style="font-size:5.64444px;stroke-width:0.264583;fill:#f9f9f9;">LLVM IR</tspan></text>
</g>
</svg>

After

Width:  |  Height:  |  Size: 19 KiB

383
docs/imgs/mlir_dia.svg Normal file
View File

@ -0,0 +1,383 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="319mm"
height="138mm"
viewBox="0 0 318.99999 138"
version="1.1"
id="svg8"
inkscape:version="1.0.2 (e86c870879, 2021-01-15)"
sodipodi:docname="llvm.svg"
inkscape:export-filename="/home/lxsameer/llvm.png"
inkscape:export-xdpi="92.360001"
inkscape:export-ydpi="92.360001">
<defs
id="defs2">
<marker
style="overflow:visible"
id="marker1383"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow1Lstart"
inkscape:isstock="true">
<path
transform="matrix(0.8,0,0,0.8,10,0)"
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt"
d="M 0,0 5,-5 -12.5,0 5,5 Z"
id="path1381" />
</marker>
<marker
style="overflow:visible"
id="marker1361"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow1Lstart"
inkscape:isstock="true">
<path
transform="matrix(0.8,0,0,0.8,10,0)"
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt"
d="M 0,0 5,-5 -12.5,0 5,5 Z"
id="path1359" />
</marker>
<marker
style="overflow:visible"
id="marker1345"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow1Lstart"
inkscape:isstock="true">
<path
transform="matrix(0.8,0,0,0.8,10,0)"
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt"
d="M 0,0 5,-5 -12.5,0 5,5 Z"
id="path1343" />
</marker>
<marker
style="overflow:visible"
id="Arrow1Lstart"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow1Lstart"
inkscape:isstock="true">
<path
transform="matrix(0.8,0,0,0.8,10,0)"
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt"
d="M 0,0 5,-5 -12.5,0 5,5 Z"
id="path1073" />
</marker>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#2f2f2f"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="1"
inkscape:pageshadow="2"
inkscape:zoom="0.7"
inkscape:cx="472.50849"
inkscape:cy="266.46612"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
inkscape:document-rotation="0"
showgrid="false"
showguides="true"
inkscape:guide-bbox="true"
inkscape:window-width="1920"
inkscape:window-height="1064"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="0"
inkscape:pagecheckerboard="false"
units="mm"
scale-x="1" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<path
style="display:none;fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 274.26769,123.45548 235.03465,76.05329"
id="path1554"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0" />
<g
id="g1617"
transform="translate(-3.1077376,-3.3836528)">
<rect
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0.307798;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect833"
width="53.575756"
height="20.157219"
x="45.531528"
y="22.062426" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.230399px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 278.95952,123.75393 295.96571,123.573"
id="path947"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0" />
<text
xml:space="preserve"
style="font-size:9.21593px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;fill:#f9f9f9;stroke-width:0.230399"
x="54.002769"
y="35.491024"
id="text971"><tspan
sodipodi:role="line"
id="tspan969"
x="54.002769"
y="35.491024"
style="fill:#f9f9f9;stroke-width:0.230399">Frontend</tspan></text>
<text
xml:space="preserve"
style="font-size:9.21593px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;fill:#f9f9f9;stroke-width:0.230399"
x="235.41437"
y="125.88704"
id="text975"><tspan
sodipodi:role="line"
id="tspan973"
x="235.41437"
y="125.88704"
style="fill:#f9f9f9;stroke-width:0.230399">Backend</tspan></text>
<text
xml:space="preserve"
style="font-size:6.14398px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;fill:#f9f9f9;stroke-width:0.230399"
x="5.0139894"
y="29.200495"
id="text997"><tspan
sodipodi:role="line"
id="tspan995"
x="5.0139894"
y="29.200495"
style="font-size:6.14398px;fill:#f9f9f9;stroke-width:0.230399">Source Code</tspan></text>
<text
xml:space="preserve"
style="font-size:6.14398px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;fill:#f9f9f9;stroke-width:0.230399"
x="282.008"
y="120.81123"
id="text1013"><tspan
sodipodi:role="line"
id="tspan1011"
x="282.008"
y="120.81123"
style="font-size:6.14398px;fill:#f9f9f9;stroke-width:0.230399">Machine Code</tspan></text>
<rect
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0.842751;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect1493"
width="65.955437"
height="122.74801"
x="128.33922"
y="16.364525" />
<g
id="g1504"
transform="translate(14.81667)">
<rect
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0.244213;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect1495"
width="40.131203"
height="16.940268"
x="125.274"
y="24.818373" />
<text
xml:space="preserve"
style="font-size:7.05556px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.264583"
x="131.3943"
y="35.853203"
id="text1499"><tspan
sodipodi:role="line"
id="tspan1497"
x="131.3943"
y="35.853203"
style="font-size:7.05556px;fill:#f9f9f9;stroke-width:0.264583">Dialect X</tspan></text>
</g>
<g
id="g1512"
transform="translate(14.81667,22.225012)">
<rect
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0.244213;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect1506"
width="40.131203"
height="16.940268"
x="125.274"
y="24.818373" />
<text
xml:space="preserve"
style="font-size:7.05556px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.264583"
x="131.3943"
y="35.853203"
id="text1510"><tspan
sodipodi:role="line"
id="tspan1508"
x="131.3943"
y="35.853203"
style="font-size:7.05556px;fill:#f9f9f9;stroke-width:0.264583">Dialect Y</tspan></text>
</g>
<g
id="g1520"
transform="translate(14.81667,43.920858)">
<rect
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0.244213;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect1514"
width="40.131203"
height="16.940268"
x="125.274"
y="24.818373" />
<text
xml:space="preserve"
style="font-size:7.05556px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.264583"
x="131.3943"
y="35.853203"
id="text1518"><tspan
sodipodi:role="line"
id="tspan1516"
x="131.3943"
y="35.853203"
style="font-size:7.05556px;fill:#f9f9f9;stroke-width:0.264583">Dialect Z</tspan></text>
</g>
<g
id="g1528"
transform="translate(14.81667,88.90005)">
<rect
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0.244213;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect1522"
width="40.131203"
height="16.940268"
x="125.274"
y="26.246077" />
<text
xml:space="preserve"
style="font-size:7.05556px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.264583"
x="145.26199"
y="32.641876"
id="text1526"><tspan
sodipodi:role="line"
id="tspan1524"
x="145.26199"
y="32.641876"
style="font-size:7.05556px;text-align:center;text-anchor:middle;fill:#f9f9f9;stroke-width:0.264583">LLVM </tspan><tspan
sodipodi:role="line"
x="145.26199"
y="41.461327"
style="font-size:7.05556px;text-align:center;text-anchor:middle;fill:#f9f9f9;stroke-width:0.264583"
id="tspan1530">Dialect</tspan></text>
<text
xml:space="preserve"
style="font-size:10.5833px;line-height:0;font-family:Charter;-inkscape-font-specification:Charter;fill:#ffffff;stroke-width:0.264583"
x="143.37328"
y="3.9393847"
id="text1534"><tspan
sodipodi:role="line"
id="tspan1532"
x="143.37328"
y="3.9393847"
style="font-size:22.5778px;line-height:0.35;fill:#ffffff;stroke-width:0.264583">.</tspan><tspan
sodipodi:role="line"
x="143.37328"
y="11.841615"
style="font-size:22.5778px;line-height:0.35;fill:#ffffff;stroke-width:0.264583"
id="tspan1536">.</tspan><tspan
sodipodi:role="line"
x="143.37328"
y="19.743845"
style="font-size:22.5778px;line-height:0.35;fill:#ffffff;stroke-width:0.264583"
id="tspan1538">.</tspan><tspan
sodipodi:role="line"
x="143.37328"
y="20.552401"
style="font-size:22.5778px;line-height:0.35;fill:#ffffff;stroke-width:0.264583"
id="tspan1540" /></text>
<path
style="fill:#ffffff;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.286366px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 165.40323,34.185302 45.30444,0.06755"
id="path1552"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0" />
</g>
<rect
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0.307798;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect1542"
width="53.575756"
height="20.157219"
x="225.66211"
y="112.45845" />
<path
style="fill:#ffffff;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 16.152169,31.098656 29.384046,-0.01103"
id="path1546"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 99.107285,32.490983 40.983385,0.535393"
id="path1548"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
inkscape:connection-start="#rect833"
inkscape:connection-end="#g1504" />
<text
xml:space="preserve"
style="font-size:10.5833px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;fill:#f9f9f9;stroke-width:0.264583"
x="138.35216"
y="12.875091"
id="text1558"><tspan
sodipodi:role="line"
id="tspan1556"
x="138.35216"
y="12.875091"
style="fill:#f9f9f9;stroke-width:0.264583">Optimizer</tspan></text>
<text
xml:space="preserve"
style="font-size:10.5833px;line-height:0;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.264583"
x="115.36226"
y="41.259983"
id="text1562"><tspan
sodipodi:role="line"
id="tspan1560"
x="115.36226"
y="41.259983"
style="font-size:7.05556px;line-height:1.05;text-align:center;text-anchor:middle;fill:#f9f9f9;stroke-width:0.264583">Some</tspan><tspan
sodipodi:role="line"
x="115.36226"
y="48.66832"
style="font-size:7.05556px;line-height:1.05;text-align:center;text-anchor:middle;fill:#f9f9f9;stroke-width:0.264583"
id="tspan1564">IR</tspan></text>
<text
xml:space="preserve"
style="font-size:10.5833px;line-height:0;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.264583"
x="211.18536"
y="111.30232"
id="text1570"><tspan
sodipodi:role="line"
id="tspan1566"
x="211.18536"
y="111.30232"
style="font-size:7.05556px;line-height:1.05;text-align:center;text-anchor:middle;fill:#f9f9f9;stroke-width:0.264583">LLVM</tspan><tspan
sodipodi:role="line"
x="211.18536"
y="118.71066"
style="font-size:7.05556px;line-height:1.05;text-align:center;text-anchor:middle;fill:#f9f9f9;stroke-width:0.264583"
id="tspan1568">IR</tspan></text>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -20,7 +20,8 @@
- Repository: https://devheroes.codes/Serene
- Website: lxsameer.com
Email: lxsameer@gnu.org
* Episode 2 - Basic Setup
* DONE Episode 2 - Basic Setup
CLOSED: [2021-07-10 Sat 09:04]
** Installing Requirements
*** LLVM and Clang
- mlir-tblgen
@ -29,3 +30,37 @@
- git hooks
** Source tree structure
** =dev.org= resources and TODOs
* Episode 3 - Overview
** Generic Compiler
- [[https://www.cs.princeton.edu/~appel/modern/ml/whichver.html][Modern Compiler Implementation in ML: Basic Techniques]]
- [[https://suif.stanford.edu/dragonbook/][Compilers: Principles, Techniques, and Tools (The Dragon Book)]]
*** Common Steps
- Lexical analyzer
- Syntax analyzer
- Semantic analyzer
- Intermediate code generation
- Code optimizer
- Target code generation
** LLVM
[[llvm.org]]
*** Watch [[https://www.youtube.com/watch?v=J5xExRGaIIY][Introdution to LLVM]]
*** Quick overview
Deducted from https://www.aosabook.org/en/llvm.html
[[./imgs/llvm_dia.svg]]
** MLIR
[[mlir.llvm.org]]
[[./imgs/mlir_dia.svg]]
** Serene
*** A Compiler frontend
*** Steps
- =serenec= in parses the command lines args
- =reader= reads the input file and generates an =AST=
- =semantic analyzer= walks the =AST= aned generates a new =AST= and rewrites
the necessary nodes.
- =slir= generator generates =slir= dialect code from =AST=.
- We lower =slir= to other dialects of the *MLIR* which we call the result =mlir=.
- Then, We lower everything to the =LLVMIR dialect= and call it =lir= (lowered IR).
- Finally we fully lower =lir= to =LLVM IR= and pass it to the object generator
to generate object files.
- Call the default =c compiler= to link the object files and generate the machine code.

View File

@ -30,10 +30,9 @@
#include "serene/exprs/expression.h"
#include "serene/llvm/IR/Value.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/raw_ostream.h"
#include <llvm/ADT/StringRef.h>
#include <llvm/Support/FormatVariadic.h>
#include <llvm/Support/raw_ostream.h>
#include <stdexcept>
#include <string>