Skip to content

Instantly share code, notes, and snippets.

package main
func f(x, y int) int {
z := x + y;
return z;
}
func main() {
/* go */ f(7, 11);
}
@phase
phase / interface.ll
Last active November 27, 2017 10:13
; ModuleID = 'interface.ll'
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%class.Concrete = type <{ %class.Interface, i32, [4 x i8] }>
%class.Interface = type { i32 (...)** }
$_ZN8ConcreteC2Ev = comdat any
$_ZN8ConcreteD2Ev = comdat any
45 00 00 10 04 00 F0 FF
46 00 00 10 0A 00 F0 FF 00 00 00 01 00 00 F0 00 00 00 F0 FF 00 00 10 00 D0 00 11 00 00 00 10 01
6E 02 00 28 01 00 F0 FF
40 00 00 10 08 00 00 11 6E 02 00 28 01 00 F0 FF
41 00 00 10 02 00 F0 FF 40 01 20 00 00 00 21 00 00 00 22 00 24 00 23 00 D0 00 24 00 04 00 27 00 01 00 25 00 02 00 26 00
42 00 00 10 04 00 F0 FF
43 00 00 10 06 00 F0 FF 00 00 24 00
44 00 00 10 00 00 20 01 08 00 F0 FF
45 00 00 10 0A 00 F0 FF 00 00 00 01 00 00 F0 00 00 00 F0 FF 00 00 10 00 D0 00 11 00 00 00 10 01
FunctionCallInstruction(functionName=internal_add_i32, registerIndexes=[0, 1]),
StoreInstruction(regIndex=2),
FunctionCallInstruction(functionName=internal_add_i32, registerIndexes=[0, 2]),
FunctionCallInstruction(functionName=internal_add_i32, registerIndexes=[3, 2]),
StoreInstruction(regIndex=3),
ReturnInstruction(registerIndex=3)
StoreInstruction(regIndex=3),
StoreInstruction(regIndex=3),
FunctionCallInstruction(functionName=internal_add_i32, registerIndexes=[0, 1]),
#include<stdlib.h>
struct Box {
int x;
};
int f(struct Box* box) {
return box->x;
}
IrFunction(name=h, returnType=Int, argumentCount=1, registerTypes=[Int, X, Int], instructions=[
HeapAllocateInstruction(type=X),
StoreInstruction(register=1),
FieldSetInstruction(structRegisterIndex=1, fieldIndex=0, valueRegisterIndex=0),
FieldGetInstruction(registerIndex=1, fieldIndex=0),
StoreInstruction(register=2),
ReturnInstruction(registerIndex=2)])], structs=[X])
IrFunction(name=h, returnType=Int, argumentCount=1, registerTypes=[Int, X, Int], instructions=[
StackAllocateInstruction(type=X),
@phase
phase / ast&ir
Last active December 9, 2017 08:10
recursive expressions
AstModule(name=parser_test, functionDeclarations=[
AstFunctionDeclaration(name=i, argumentTypes=[Int32], returnType=AstStruct{Y}, permissions=[])], functionDefinitions=[
AstFunctionDefinition(name=i, arguments=[a], statements=[
VariableAssignmentStatement(name=x, expression=
AllocateStructExpression(struct=X, expressions=
[IdentifierExpression(name=a)])),
VariableAssignmentStatement(name=__return_expression, expression=
AllocateStructExpression(struct=Y, expressions=[
IdentifierExpression(name=x)])),
ReturnStatement(expression=
32, 56, 124, 32, 107, 32, 58, 58, 32, 88, 32, 45, 62, 32, 89, 10, 32, 57, 124, 32, 107, 32, 120, 32, 61, 32, 89, 123, 120, 125, 46, 10, 32, 32, 124, 32, 126, 126, 126, 126, 126, 126, 126, 126, 94, 10, 49, 48, 124, 32, 10, 69, 114, 114, 111, 114, 58, 32, 84, 114, 121, 105, 110, 103, 32, 116, 111, 32, 115, 116, 111, 114, 101, 32, 97, 114, 103, 117, 109, 101, 110, 116, 32, 112, 111, 105, 110, 116, 101, 114, 32, 105, 110, 116, 111, 32, 97, 32, 108, 111, 99, 97, 108, 32, 115, 116, 114, 117, 99, 116
JFrame took 0.009548935s
Config took 0.046662874s
Sonic Palette took 0.255192107s
Knuckles Palette took 0.003669708s
Tails Palette took 0.003472774s
Shadow Palette took 0.004536207s
Rouge Palette took 0.006939667s
Amy Palette took 0.003259934s
E102 Palette took 0.004125171s
Cream Palette took 0.004338449s
; ModuleID = '/tmp/compiler-explorer-compiler1171124-54-68xhxt.z6gmf/example.cpp'
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: noinline nounwind optnone uwtable
define i32 @square(int)(i32) #0 !dbg !7 {
%2 = alloca i32, align 4
%3 = alloca i32, align 4
store i32 %0, i32* %3, align 4
call void @llvm.dbg.declare(metadata i32* %3, metadata !11, metadata !12), !dbg !13