2017年6月の記事一覧
OSX の gcc を更新
OSX の gcc を変更した話 ports
macのgcc(clang)からgcc6.3にしたい
brew install gcc
Warning: gcc 7.1.0 is already installed
gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
きつねさんでもわかるLLVM コンパイラを自作するためのガイドブック第5章
柏木 餅子, 風薬
インプレス(2013/06/21)
p.59
p.62
int test(int j){
int I;
i=j*10;
return I;
}
int main(){
int I;
=10; printnum(test(i));
return 0;
}
きつねさんでもわかるLLVM コンパイラを自作するためのガイドブック第4章
柏木 餅子, 風薬
インプレス(2013/06/21)
4.5 基本的なLLVM の中間表現.
p.41
#include <stdio.h>
int main(){
printf("HelloWorld\n");
return 0;
}
$ clang -emit-llvm -S -o helloworld.ll helloworld.c
$ cat hello world.ll
; ModuleID = 'helloworld.c'
source_filename = "helloworld.c"
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.12.0"
@.str = private unnamed_addr constant [12 x i8] c"HelloWorld\0A\00", align 1
; Function Attrs: nounwind ssp uwtable
define i32 @main() #0 {
%1 = alloca i32, align 4
store i32 0, i32* %1, align 4
%2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i32 0, i32 0))
ret i32 0
}
declare i32 @printf(i8*, ...) #1
attributes #0 = { nounwind ssp uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+fxsr,+mmx,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+fxsr,+mmx,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
!llvm.module.flags = !{!0}
!llvm.ident = !{!1}
!0 = !{i32 1, !"PIC Level", i32 2}
!1 = !{!"Apple LLVM version 8.1.0 (clang-802.0.42)"}
でき
きつねさんでもわかるLLVM 達人出版会 1,150円+税 2012-2014
きつねさんとおぼえるLLVM (LLVM解説本) をC83で出します 2012
きつねさんでもわかるLLVM読書会amagasaki.rb第5章
Kmotiko/DummyCCompiler https://github.com/Kmotiko/DummyCCompiler
LLVM
1.
cat hoge.c
int main(int x){
return printf("%d\r",x)
}
2.
clang hoge.c
hoge.c:1:5: warning: only one parameter on 'main' declaration [-Wmain]
int main(int x){
^
hoge.c:2:9: warning: implicitly declaring library function 'printf' with type
'int (const char *, ...)' [-Wimplicit-function-declaration]
return printf("%d\r",x)
^
hoge.c:2:9: note: include the header <stdio.h> or explicitly provide a declaration for
'printf'
hoge.c:2:25: error: expected ';' after return statement
return printf("%d\r",x)
^
;
2 warnings and 1 error generated.
3.
#include <stdio.h>
int main(int argc, char** argv){
return printf("%d\r",argc);
}
4.
#include <stdio.h>
int main(int argc, char** argv){
return printf("argc = %d\n",argc);
}
$ clang hoge3.c
$ ./a.out
argc = 1
5
clang -v
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
https://researchmap.jp/jomiiye6v-1797580/#_1797580
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf
cpp2011//20.6.8 Allocator traits X
cpp2011//20.6.9 The default allocator X
cpp2011//20.6.10 Raw storage iterator X
http://www.graco.c.u-tokyo.ac.jp/icpc-challenge/wp-content/uploads/2014/12/2014.pdf