SlideShare ist ein Scribd-Unternehmen logo
1 von 26
Downloaden Sie, um offline zu lesen
LLVM
       2009   1   15   ( )
LLVM
       Tatsuhiro Ujihisa
LLVM
     The Low Level Virtual Machine (LLVM) is a compiler
infrastructure, written in C++, which is designed for compile-
  time, link-time, run-time, and "idle-time" optimization of
programs written in arbitrary programming languages. LLVM
 was originally developed as a research infrastructure at the
  University of Illinois at Urbana-Champaign to investigate
  dynamic compilation techniques for static and dynamic
                 programming languages...

  http://en.wikipedia.org/wiki/Low_Level_Virtual_Machine
In short,
            C   JVM
     gcc
            (    )
                 (    )
C
             C→         →   →

$   vim a.c
$   gcc a.c -S -o a.s
$   gcc a.s -o a
$   ./a
LLVM                   (1)
C → LLVM          → LLVM         →


$   vim a.c
$   llvm-gcc a.c -S -o a.ll
$   llvm-as a.ll -o a.bc
$   lli a.bc
LLVM                  (2)
    C → LLVM      → LLVM         →   →

$   vim a.c
$   llvm-gcc a.c -S -o a.ll
$   llvm-as a.ll -o a.bc
$   llc a.bc -o a
$   ./a
LLVM                   (3)
LLVM         → LLVM            →

$ vim a.ll
$ llvm-as a.ll -o a.bc
$ lli a.bc
LLVM                   (4)
LLVM          → LLVM             →   →


$   vim a.ll
$   llvm-as a.ll -o a.bc
$   opt a.bc -o a2.bc
$   lli a2.bc
LLVM                (5)
LLVM          → LLVM          →   →   →


$   vim a.ll
$   llvm-as a.ll -o a.bc
$   opt -O3 a.bc -o a2.bc
$   opt -O3 a2.bc -o a3.bc
$   lli a3.bc
LLVM


$   llvm-as a.ll -o a.bc
$   opt -O3 a.bc -o a2.bc
$   opt -O3 a2.bc -o a3.bc
$   llvm-dis a3.bc -o a3.ll
$   vim a3.ll
llvm-as: LLVM                                  (.ll)
LLVM                  (.bc)
lli: LLVM                     (.bc)
opt: LLVM                     (.bc)                    LLVM
              (.bc)
llvm-dis: llvm-as
llvm-gcc: C                      (.c)   LLVM
   (.ll)
LLVM                            Hello,
  world!
                  Hello, world!

@str = internal constant [14 x i8] c"Hello, world!00"
declare i32 @puts(i8*)
define i32 @main()
{
  call i32 @puts( i8* getelementptr ([14 x i8]* @str, i32
  ret i32 0
}
LLVM


       (   )
  C
Vim   quickrun   LLVM
.ll                    <Space>r   llvm-as lli
LLVM

                               LLVM
                       OK (C          OK)
  LLVM   Mac, Linux, Windows
LLVM                (             )
  C (llvm-gcc)
  Perl
  Python (pypy)
  Ruby (Rubinius, MacRuby, etc)
  Haskell
  Brainf**k
  ... LLVM
LLVM
                    Pure


            (   )


  Haskell
  sudo port install pure
LLVM
          LLVM
   LLVM
(          )
LLVM
  (MacRuby)
              (   svn up)
!
      Brainf**k → LLVM
BFC: Brainf**k Compiler
git clone
git://github.com/ujihisa/bfc.git
vim bfc/bfc.rb
:+
  +:

/* C              */
/* char *h             */
++*h;

LLVM                        !→
                                 OK
(bfc.rb           )
when '+'
  a = tc +=   1; b = tc += 1; c = tc += 1; d = tc += 1
  "%tmp#{a}   = load i32* %i, align 4n" <<
  "%tmp#{b}   = getelementptr [1024 x i8]* %h, i32 0, i32 %
  "%tmp#{c}   = load i8* %tmp#{b}, align 1n" <<
  "%tmp#{d}   = add i8 1, %tmp#{c}n" <<
  "store i8   %tmp#{d}, i8* %tmp#{b}, align 1n"

1.
2.
3.
4.            1
$ cat helloworld.bf
$ cat helloworld.bf | ruby bfc.rb --llvm > helloworld.ll
$ llvm-as helloworld.ll > helloworld.bc
$ opt -O3 helloworld.bc #
$ lli helloworld.bc
Hello, world!



$ ruby bfc.rb --llvm helloworld.bf --run
:
BFC: Brainf**k Compilers
         http://ujihisa.blogspot.com/2009/12/bfc-
         brainfk-compilers.html
LLVM For Starters
         http://ujihisa.blogspot.com/2009/12/llvm-
         for-starters.html
Let's Try LLVM
         http://ujihisa.blogspot.com/2009/12/let-
         try-llvm.html
nil   try-llvm.html

Weitere ähnliche Inhalte

Was ist angesagt?

Introduction to rust: a low-level language with high-level abstractions
Introduction to rust: a low-level language with high-level abstractionsIntroduction to rust: a low-level language with high-level abstractions
Introduction to rust: a low-level language with high-level abstractionsyann_s
 
Type script in practice
Type script in practiceType script in practice
Type script in practiceBryan Hughes
 
Groovify your java code by hervé roussel
Groovify your java code by hervé rousselGroovify your java code by hervé roussel
Groovify your java code by hervé rousselHervé Vũ Roussel
 
C++ hello world
C++ hello worldC++ hello world
C++ hello worldAL- AMIN
 
All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2goMoriyoshi Koizumi
 
最近作ったN個のCPANモジュール Yokohama.pm #10
最近作ったN個のCPANモジュール Yokohama.pm #10最近作ったN個のCPANモジュール Yokohama.pm #10
最近作ったN個のCPANモジュール Yokohama.pm #10Masahiro Nagano
 
PyCon KR 2019 sprint - RustPython by example
PyCon KR 2019 sprint  - RustPython by examplePyCon KR 2019 sprint  - RustPython by example
PyCon KR 2019 sprint - RustPython by exampleYunWon Jeong
 
Guile 3: Faster programs via just-in-time compilation (FOSDEM 2019)
Guile 3: Faster programs via just-in-time compilation (FOSDEM 2019)Guile 3: Faster programs via just-in-time compilation (FOSDEM 2019)
Guile 3: Faster programs via just-in-time compilation (FOSDEM 2019)Igalia
 
Cryptography for Smalltalkers - ESUG 2004
Cryptography for Smalltalkers - ESUG 2004Cryptography for Smalltalkers - ESUG 2004
Cryptography for Smalltalkers - ESUG 2004Martin Kobetic
 
SdE 2: Le langage Python, Allocation de memoire
SdE 2: Le langage Python, Allocation de memoireSdE 2: Le langage Python, Allocation de memoire
SdE 2: Le langage Python, Allocation de memoireAlexandru Radovici
 
関西Vim勉強会#5 vimrcの書き方
関西Vim勉強会#5 vimrcの書き方関西Vim勉強会#5 vimrcの書き方
関西Vim勉強会#5 vimrcの書き方tsukkee _
 

Was ist angesagt? (20)

Let's Go-lang
Let's Go-langLet's Go-lang
Let's Go-lang
 
Introduction to rust: a low-level language with high-level abstractions
Introduction to rust: a low-level language with high-level abstractionsIntroduction to rust: a low-level language with high-level abstractions
Introduction to rust: a low-level language with high-level abstractions
 
dplyr
dplyrdplyr
dplyr
 
Type script in practice
Type script in practiceType script in practice
Type script in practice
 
Libtcc and gwan
Libtcc and gwanLibtcc and gwan
Libtcc and gwan
 
Groovify your java code by hervé roussel
Groovify your java code by hervé rousselGroovify your java code by hervé roussel
Groovify your java code by hervé roussel
 
C++ hello world
C++ hello worldC++ hello world
C++ hello world
 
All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2go
 
Go for Rubyists
Go for RubyistsGo for Rubyists
Go for Rubyists
 
最近作ったN個のCPANモジュール Yokohama.pm #10
最近作ったN個のCPANモジュール Yokohama.pm #10最近作ったN個のCPANモジュール Yokohama.pm #10
最近作ったN個のCPANモジュール Yokohama.pm #10
 
PyCon KR 2019 sprint - RustPython by example
PyCon KR 2019 sprint  - RustPython by examplePyCon KR 2019 sprint  - RustPython by example
PyCon KR 2019 sprint - RustPython by example
 
Clojure+ClojureScript Webapps
Clojure+ClojureScript WebappsClojure+ClojureScript Webapps
Clojure+ClojureScript Webapps
 
GoでKVSを書けるのか
GoでKVSを書けるのかGoでKVSを書けるのか
GoでKVSを書けるのか
 
The Big Three
The Big ThreeThe Big Three
The Big Three
 
Jose dossantos.doc
Jose dossantos.docJose dossantos.doc
Jose dossantos.doc
 
Guile 3: Faster programs via just-in-time compilation (FOSDEM 2019)
Guile 3: Faster programs via just-in-time compilation (FOSDEM 2019)Guile 3: Faster programs via just-in-time compilation (FOSDEM 2019)
Guile 3: Faster programs via just-in-time compilation (FOSDEM 2019)
 
ECMAScript 2015 Tips & Traps
ECMAScript 2015 Tips & TrapsECMAScript 2015 Tips & Traps
ECMAScript 2015 Tips & Traps
 
Cryptography for Smalltalkers - ESUG 2004
Cryptography for Smalltalkers - ESUG 2004Cryptography for Smalltalkers - ESUG 2004
Cryptography for Smalltalkers - ESUG 2004
 
SdE 2: Le langage Python, Allocation de memoire
SdE 2: Le langage Python, Allocation de memoireSdE 2: Le langage Python, Allocation de memoire
SdE 2: Le langage Python, Allocation de memoire
 
関西Vim勉強会#5 vimrcの書き方
関西Vim勉強会#5 vimrcの書き方関西Vim勉強会#5 vimrcの書き方
関西Vim勉強会#5 vimrcの書き方
 

Ähnlich wie LLVM Workshop Osaka Umeda, Japan

Building a DSL with GraalVM (CodeOne)
Building a DSL with GraalVM (CodeOne)Building a DSL with GraalVM (CodeOne)
Building a DSL with GraalVM (CodeOne)Maarten Mulders
 
不深不淺,帶你認識 LLVM (Found LLVM in your life)
不深不淺,帶你認識 LLVM (Found LLVM in your life)不深不淺,帶你認識 LLVM (Found LLVM in your life)
不深不淺,帶你認識 LLVM (Found LLVM in your life)Douglas Chen
 
Build Systems with autoconf, automake and libtool [updated]
Build Systems with autoconf, automake and libtool [updated]Build Systems with autoconf, automake and libtool [updated]
Build Systems with autoconf, automake and libtool [updated]Benny Siegert
 
我在豆瓣使用Emacs
我在豆瓣使用Emacs我在豆瓣使用Emacs
我在豆瓣使用Emacs董 伟明
 
Composer, putting dependencies on the score
Composer, putting dependencies on the scoreComposer, putting dependencies on the score
Composer, putting dependencies on the scoreRafael Dohms
 
C Under Linux
C Under LinuxC Under Linux
C Under Linuxmohan43u
 
Building a DSL with GraalVM (VoxxedDays Luxembourg)
Building a DSL with GraalVM (VoxxedDays Luxembourg)Building a DSL with GraalVM (VoxxedDays Luxembourg)
Building a DSL with GraalVM (VoxxedDays Luxembourg)Maarten Mulders
 
Composer for busy developers - DPC13
Composer for busy developers - DPC13Composer for busy developers - DPC13
Composer for busy developers - DPC13Rafael Dohms
 
DevOps(4) : Ansible(2) - (MOSG)
DevOps(4) : Ansible(2) - (MOSG)DevOps(4) : Ansible(2) - (MOSG)
DevOps(4) : Ansible(2) - (MOSG)Soshi Nemoto
 
Im trying to run make qemu-nox In a putty terminal but it.pdf
Im trying to run  make qemu-nox  In a putty terminal but it.pdfIm trying to run  make qemu-nox  In a putty terminal but it.pdf
Im trying to run make qemu-nox In a putty terminal but it.pdfmaheshkumar12354
 
03 - Refresher on buffer overflow in the old days
03 - Refresher on buffer overflow in the old days03 - Refresher on buffer overflow in the old days
03 - Refresher on buffer overflow in the old daysAlexandre Moneger
 
A world to win: WebAssembly for the rest of us
A world to win: WebAssembly for the rest of usA world to win: WebAssembly for the rest of us
A world to win: WebAssembly for the rest of usIgalia
 
Bolt C++ Standard Template Libary for HSA by Ben Sanders, AMD
Bolt C++ Standard Template Libary for HSA  by Ben Sanders, AMDBolt C++ Standard Template Libary for HSA  by Ben Sanders, AMD
Bolt C++ Standard Template Libary for HSA by Ben Sanders, AMDHSA Foundation
 
Valgrind overview: runtime memory checker and a bit more aka использование #v...
Valgrind overview: runtime memory checker and a bit more aka использование #v...Valgrind overview: runtime memory checker and a bit more aka использование #v...
Valgrind overview: runtime memory checker and a bit more aka использование #v...Minsk Linux User Group
 
DEF CON 27 - PATRICK WARDLE - harnessing weapons of Mac destruction
DEF CON 27 - PATRICK WARDLE - harnessing weapons of Mac destructionDEF CON 27 - PATRICK WARDLE - harnessing weapons of Mac destruction
DEF CON 27 - PATRICK WARDLE - harnessing weapons of Mac destructionFelipe Prado
 

Ähnlich wie LLVM Workshop Osaka Umeda, Japan (20)

Why MacRuby Matters
Why MacRuby MattersWhy MacRuby Matters
Why MacRuby Matters
 
Building a DSL with GraalVM (CodeOne)
Building a DSL with GraalVM (CodeOne)Building a DSL with GraalVM (CodeOne)
Building a DSL with GraalVM (CodeOne)
 
不深不淺,帶你認識 LLVM (Found LLVM in your life)
不深不淺,帶你認識 LLVM (Found LLVM in your life)不深不淺,帶你認識 LLVM (Found LLVM in your life)
不深不淺,帶你認識 LLVM (Found LLVM in your life)
 
Build Systems with autoconf, automake and libtool [updated]
Build Systems with autoconf, automake and libtool [updated]Build Systems with autoconf, automake and libtool [updated]
Build Systems with autoconf, automake and libtool [updated]
 
我在豆瓣使用Emacs
我在豆瓣使用Emacs我在豆瓣使用Emacs
我在豆瓣使用Emacs
 
Gun make
Gun makeGun make
Gun make
 
MacRuby, an introduction
MacRuby, an introductionMacRuby, an introduction
MacRuby, an introduction
 
Composer, putting dependencies on the score
Composer, putting dependencies on the scoreComposer, putting dependencies on the score
Composer, putting dependencies on the score
 
C Under Linux
C Under LinuxC Under Linux
C Under Linux
 
Shrink to grow
Shrink to growShrink to grow
Shrink to grow
 
005 skyeye
005 skyeye005 skyeye
005 skyeye
 
Building a DSL with GraalVM (VoxxedDays Luxembourg)
Building a DSL with GraalVM (VoxxedDays Luxembourg)Building a DSL with GraalVM (VoxxedDays Luxembourg)
Building a DSL with GraalVM (VoxxedDays Luxembourg)
 
Composer for busy developers - DPC13
Composer for busy developers - DPC13Composer for busy developers - DPC13
Composer for busy developers - DPC13
 
DevOps(4) : Ansible(2) - (MOSG)
DevOps(4) : Ansible(2) - (MOSG)DevOps(4) : Ansible(2) - (MOSG)
DevOps(4) : Ansible(2) - (MOSG)
 
Im trying to run make qemu-nox In a putty terminal but it.pdf
Im trying to run  make qemu-nox  In a putty terminal but it.pdfIm trying to run  make qemu-nox  In a putty terminal but it.pdf
Im trying to run make qemu-nox In a putty terminal but it.pdf
 
03 - Refresher on buffer overflow in the old days
03 - Refresher on buffer overflow in the old days03 - Refresher on buffer overflow in the old days
03 - Refresher on buffer overflow in the old days
 
A world to win: WebAssembly for the rest of us
A world to win: WebAssembly for the rest of usA world to win: WebAssembly for the rest of us
A world to win: WebAssembly for the rest of us
 
Bolt C++ Standard Template Libary for HSA by Ben Sanders, AMD
Bolt C++ Standard Template Libary for HSA  by Ben Sanders, AMDBolt C++ Standard Template Libary for HSA  by Ben Sanders, AMD
Bolt C++ Standard Template Libary for HSA by Ben Sanders, AMD
 
Valgrind overview: runtime memory checker and a bit more aka использование #v...
Valgrind overview: runtime memory checker and a bit more aka использование #v...Valgrind overview: runtime memory checker and a bit more aka использование #v...
Valgrind overview: runtime memory checker and a bit more aka использование #v...
 
DEF CON 27 - PATRICK WARDLE - harnessing weapons of Mac destruction
DEF CON 27 - PATRICK WARDLE - harnessing weapons of Mac destructionDEF CON 27 - PATRICK WARDLE - harnessing weapons of Mac destruction
DEF CON 27 - PATRICK WARDLE - harnessing weapons of Mac destruction
 

Mehr von ujihisa

vimconf2013
vimconf2013vimconf2013
vimconf2013ujihisa
 
KOF2013 Minecraft / Clojure
KOF2013 Minecraft / ClojureKOF2013 Minecraft / Clojure
KOF2013 Minecraft / Clojureujihisa
 
Keynote ujihisa.vim#2
Keynote ujihisa.vim#2Keynote ujihisa.vim#2
Keynote ujihisa.vim#2ujihisa
 
vimshell made other shells legacy
vimshell made other shells legacyvimshell made other shells legacy
vimshell made other shells legacyujihisa
 
From Ruby to Haskell (Kansai Yami RubyKaigi)
From Ruby to Haskell (Kansai Yami RubyKaigi)From Ruby to Haskell (Kansai Yami RubyKaigi)
From Ruby to Haskell (Kansai Yami RubyKaigi)ujihisa
 
Text Manipulation with/without Parsec
Text Manipulation with/without ParsecText Manipulation with/without Parsec
Text Manipulation with/without Parsecujihisa
 
CoffeeScript in hootsuite
CoffeeScript in hootsuiteCoffeeScript in hootsuite
CoffeeScript in hootsuiteujihisa
 
HootSuite Dev 2
HootSuite Dev 2HootSuite Dev 2
HootSuite Dev 2ujihisa
 
Ruby Kansai49
Ruby Kansai49Ruby Kansai49
Ruby Kansai49ujihisa
 
Hootsuite dev 2011
Hootsuite dev 2011Hootsuite dev 2011
Hootsuite dev 2011ujihisa
 
RubyConf 2009 LT "Termtter"
RubyConf 2009 LT "Termtter"RubyConf 2009 LT "Termtter"
RubyConf 2009 LT "Termtter"ujihisa
 
Hacking parse.y (RubyConf 2009)
Hacking parse.y (RubyConf 2009)Hacking parse.y (RubyConf 2009)
Hacking parse.y (RubyConf 2009)ujihisa
 
Hacking parse.y (RubyKansai38)
Hacking parse.y (RubyKansai38)Hacking parse.y (RubyKansai38)
Hacking parse.y (RubyKansai38)ujihisa
 
Hacking Parse.y with ujihisa
Hacking Parse.y with ujihisaHacking Parse.y with ujihisa
Hacking Parse.y with ujihisaujihisa
 
Ruby Kansai #35 About RubyKaigi2009 ujihisa
Ruby Kansai #35 About RubyKaigi2009 ujihisaRuby Kansai #35 About RubyKaigi2009 ujihisa
Ruby Kansai #35 About RubyKaigi2009 ujihisaujihisa
 
Kof2008 Itll
Kof2008 ItllKof2008 Itll
Kof2008 Itllujihisa
 
All About Metarw -- VimM#2
All About Metarw -- VimM#2All About Metarw -- VimM#2
All About Metarw -- VimM#2ujihisa
 
Itc2008 Ujihisa
Itc2008 UjihisaItc2008 Ujihisa
Itc2008 Ujihisaujihisa
 
Agile Web Posting With Ruby / Ruby Kaigi2008
Agile Web Posting With Ruby / Ruby Kaigi2008Agile Web Posting With Ruby / Ruby Kaigi2008
Agile Web Posting With Ruby / Ruby Kaigi2008ujihisa
 
Agile Web Posting with Ruby (lang:ja)
Agile Web Posting with Ruby (lang:ja)Agile Web Posting with Ruby (lang:ja)
Agile Web Posting with Ruby (lang:ja)ujihisa
 

Mehr von ujihisa (20)

vimconf2013
vimconf2013vimconf2013
vimconf2013
 
KOF2013 Minecraft / Clojure
KOF2013 Minecraft / ClojureKOF2013 Minecraft / Clojure
KOF2013 Minecraft / Clojure
 
Keynote ujihisa.vim#2
Keynote ujihisa.vim#2Keynote ujihisa.vim#2
Keynote ujihisa.vim#2
 
vimshell made other shells legacy
vimshell made other shells legacyvimshell made other shells legacy
vimshell made other shells legacy
 
From Ruby to Haskell (Kansai Yami RubyKaigi)
From Ruby to Haskell (Kansai Yami RubyKaigi)From Ruby to Haskell (Kansai Yami RubyKaigi)
From Ruby to Haskell (Kansai Yami RubyKaigi)
 
Text Manipulation with/without Parsec
Text Manipulation with/without ParsecText Manipulation with/without Parsec
Text Manipulation with/without Parsec
 
CoffeeScript in hootsuite
CoffeeScript in hootsuiteCoffeeScript in hootsuite
CoffeeScript in hootsuite
 
HootSuite Dev 2
HootSuite Dev 2HootSuite Dev 2
HootSuite Dev 2
 
Ruby Kansai49
Ruby Kansai49Ruby Kansai49
Ruby Kansai49
 
Hootsuite dev 2011
Hootsuite dev 2011Hootsuite dev 2011
Hootsuite dev 2011
 
RubyConf 2009 LT "Termtter"
RubyConf 2009 LT "Termtter"RubyConf 2009 LT "Termtter"
RubyConf 2009 LT "Termtter"
 
Hacking parse.y (RubyConf 2009)
Hacking parse.y (RubyConf 2009)Hacking parse.y (RubyConf 2009)
Hacking parse.y (RubyConf 2009)
 
Hacking parse.y (RubyKansai38)
Hacking parse.y (RubyKansai38)Hacking parse.y (RubyKansai38)
Hacking parse.y (RubyKansai38)
 
Hacking Parse.y with ujihisa
Hacking Parse.y with ujihisaHacking Parse.y with ujihisa
Hacking Parse.y with ujihisa
 
Ruby Kansai #35 About RubyKaigi2009 ujihisa
Ruby Kansai #35 About RubyKaigi2009 ujihisaRuby Kansai #35 About RubyKaigi2009 ujihisa
Ruby Kansai #35 About RubyKaigi2009 ujihisa
 
Kof2008 Itll
Kof2008 ItllKof2008 Itll
Kof2008 Itll
 
All About Metarw -- VimM#2
All About Metarw -- VimM#2All About Metarw -- VimM#2
All About Metarw -- VimM#2
 
Itc2008 Ujihisa
Itc2008 UjihisaItc2008 Ujihisa
Itc2008 Ujihisa
 
Agile Web Posting With Ruby / Ruby Kaigi2008
Agile Web Posting With Ruby / Ruby Kaigi2008Agile Web Posting With Ruby / Ruby Kaigi2008
Agile Web Posting With Ruby / Ruby Kaigi2008
 
Agile Web Posting with Ruby (lang:ja)
Agile Web Posting with Ruby (lang:ja)Agile Web Posting with Ruby (lang:ja)
Agile Web Posting with Ruby (lang:ja)
 

Kürzlich hochgeladen

Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 

Kürzlich hochgeladen (20)

Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 

LLVM Workshop Osaka Umeda, Japan

  • 1. LLVM 2009 1 15 ( )
  • 2. LLVM Tatsuhiro Ujihisa
  • 3. LLVM The Low Level Virtual Machine (LLVM) is a compiler infrastructure, written in C++, which is designed for compile- time, link-time, run-time, and "idle-time" optimization of programs written in arbitrary programming languages. LLVM was originally developed as a research infrastructure at the University of Illinois at Urbana-Champaign to investigate dynamic compilation techniques for static and dynamic programming languages... http://en.wikipedia.org/wiki/Low_Level_Virtual_Machine
  • 4. In short, C JVM gcc ( ) ( )
  • 5. C C→ → → $ vim a.c $ gcc a.c -S -o a.s $ gcc a.s -o a $ ./a
  • 6. LLVM (1) C → LLVM → LLVM → $ vim a.c $ llvm-gcc a.c -S -o a.ll $ llvm-as a.ll -o a.bc $ lli a.bc
  • 7. LLVM (2) C → LLVM → LLVM → → $ vim a.c $ llvm-gcc a.c -S -o a.ll $ llvm-as a.ll -o a.bc $ llc a.bc -o a $ ./a
  • 8. LLVM (3) LLVM → LLVM → $ vim a.ll $ llvm-as a.ll -o a.bc $ lli a.bc
  • 9. LLVM (4) LLVM → LLVM → → $ vim a.ll $ llvm-as a.ll -o a.bc $ opt a.bc -o a2.bc $ lli a2.bc
  • 10. LLVM (5) LLVM → LLVM → → → $ vim a.ll $ llvm-as a.ll -o a.bc $ opt -O3 a.bc -o a2.bc $ opt -O3 a2.bc -o a3.bc $ lli a3.bc
  • 11. LLVM $ llvm-as a.ll -o a.bc $ opt -O3 a.bc -o a2.bc $ opt -O3 a2.bc -o a3.bc $ llvm-dis a3.bc -o a3.ll $ vim a3.ll
  • 12. llvm-as: LLVM (.ll) LLVM (.bc) lli: LLVM (.bc) opt: LLVM (.bc) LLVM (.bc) llvm-dis: llvm-as llvm-gcc: C (.c) LLVM (.ll)
  • 13. LLVM Hello, world! Hello, world! @str = internal constant [14 x i8] c"Hello, world!00" declare i32 @puts(i8*) define i32 @main() { call i32 @puts( i8* getelementptr ([14 x i8]* @str, i32 ret i32 0 }
  • 14. LLVM ( ) C
  • 15. Vim quickrun LLVM .ll <Space>r llvm-as lli
  • 16. LLVM LLVM OK (C OK) LLVM Mac, Linux, Windows
  • 17. LLVM ( ) C (llvm-gcc) Perl Python (pypy) Ruby (Rubinius, MacRuby, etc) Haskell Brainf**k ... LLVM
  • 18. LLVM Pure ( ) Haskell sudo port install pure
  • 19. LLVM LLVM LLVM
  • 20. ( ) LLVM (MacRuby) ( svn up)
  • 21. ! Brainf**k → LLVM BFC: Brainf**k Compiler git clone git://github.com/ujihisa/bfc.git vim bfc/bfc.rb
  • 22. :+ +: /* C */ /* char *h */ ++*h; LLVM !→ OK
  • 23. (bfc.rb ) when '+' a = tc += 1; b = tc += 1; c = tc += 1; d = tc += 1 "%tmp#{a} = load i32* %i, align 4n" << "%tmp#{b} = getelementptr [1024 x i8]* %h, i32 0, i32 % "%tmp#{c} = load i8* %tmp#{b}, align 1n" << "%tmp#{d} = add i8 1, %tmp#{c}n" << "store i8 %tmp#{d}, i8* %tmp#{b}, align 1n" 1. 2. 3. 4. 1
  • 24. $ cat helloworld.bf $ cat helloworld.bf | ruby bfc.rb --llvm > helloworld.ll $ llvm-as helloworld.ll > helloworld.bc $ opt -O3 helloworld.bc # $ lli helloworld.bc Hello, world! $ ruby bfc.rb --llvm helloworld.bf --run
  • 25. : BFC: Brainf**k Compilers http://ujihisa.blogspot.com/2009/12/bfc- brainfk-compilers.html LLVM For Starters http://ujihisa.blogspot.com/2009/12/llvm- for-starters.html Let's Try LLVM http://ujihisa.blogspot.com/2009/12/let- try-llvm.html
  • 26. nil try-llvm.html