[llvm-commits] [www] r139976 - in /www/trunk/demo: DemoInfo.html index.cgi

David Blaikie dblaikie at gmail.com
Fri Sep 16 18:42:58 PDT 2011


Author: dblaikie
Date: Fri Sep 16 20:42:58 2011
New Revision: 139976

URL: http://llvm.org/viewvc/llvm-project?rev=139976&view=rev
Log:
Update the LLVM demo page to include architecture choice (x86-64, x86-32, LLVM assemmbly, LLVM C++ API). Contribution by Bjarke Walling.

Modified:
    www/trunk/demo/DemoInfo.html
    www/trunk/demo/index.cgi

Modified: www/trunk/demo/DemoInfo.html
URL: http://llvm.org/viewvc/llvm-project/www/trunk/demo/DemoInfo.html?rev=139976&r1=139975&r2=139976&view=diff
==============================================================================
--- www/trunk/demo/DemoInfo.html (original)
+++ www/trunk/demo/DemoInfo.html Fri Sep 16 20:42:58 2011
@@ -30,14 +30,12 @@
 </ul>
 
 
-<h2><a name="demangle">Demangle C++ names with C++ filt</a></h2>
+<h2><a name="language">Source language</a></h2>
 
 <p>
-Select this option if you want to run the output LLVM IR through "c++filt", 
-which converts 'mangled' C++ names to their unmangled version. 
-Note that LLVM code produced will not be lexically valid, but it will 
-be easier to understand.
-</p>
+Select the type of source code you want to compile. If you upload a file you
+don't need this as the language is detected from the file extension.</p>
+
 
 <h2><a name="optlevel">Optimization level</a></h2>
 
@@ -74,23 +72,45 @@
 optimizers.</p>
 
 
-<h2><a name="bcanalyzer">Analyze generated bytecode</a></h2>
+<h2><a name="demangle">Demangle C++ names with C++ filt</a></h2>
 
 <p>
-Select this option to run the <a 
-href="http://llvm.org/cmds/llvm-bcanalyzer.html">llvm-bcanalyzer</a> tool
-on the generated bytecode, which introspects into the format of the .bc file
-itself.  </p>
+Select this option if you want to run the target output code through "c++filt", 
+which converts 'mangled' C++ names to their unmangled version. 
+Note that target code produced will not be lexically valid, but it will 
+be easier to understand.
+</p>
 
 
-<h2><a name="llvm2cpp">Show C++ API code</a></h2>
+<h2><a name="target">Target</a></h2>
+
+<p>
+Select the target you want to output code for. Generally a target uses the
+<a href="http://llvm.org/cmds/llc.html">llc</a> tool to output machine assembly
+code. However, a few special targets exists: </p>
+<dl>
+
+  <dt><tt><b>LLVM assembly</b></tt>: </dt>
+<dd>
+Select this option to run the LLVM dissambler
+(<a href="http://llvm.org/cmds/llvm-dis.html">llvm-dis</a> tool) to show the LLVM IR.
+</dd>
+
+  <dt><tt><b>LLVM C++ API code</b></tt>: </dt>
+<dd>
+Select this option to auto generate the C++ API calls that could be used to
+create the .bc file.
+</dd>
+</dl>
+
+
+<h2><a name="bcanalyzer">Analyze generated bytecode</a></h2>
 
 <p>
 Select this option to run the <a 
-href="http://llvm.org/cmds/llvm2cpp.html">llvm2cpp</a> tool
-on the generated bytecode, which auto generates the C++ API calls that could
-be used to create the .bc file.
-</p>
+href="http://llvm.org/cmds/llvm-bcanalyzer.html">llvm-bcanalyzer</a> tool
+on the generated bytecode, which introspects into the format of the .bc file
+itself.  </p>
 
 </body>
 </html>

Modified: www/trunk/demo/index.cgi
URL: http://llvm.org/viewvc/llvm-project/www/trunk/demo/index.cgi?rev=139976&r1=139975&r2=139976&view=diff
==============================================================================
--- www/trunk/demo/index.cgi (original)
+++ www/trunk/demo/index.cgi Fri Sep 16 20:42:58 2011
@@ -159,6 +159,18 @@
 </td></tr></table><p>
 END
 
+my %llvmTargets = ();
+$llvmTargets{'x86'} = { label => '32-bit X86: Pentium-Pro and above'  };
+$llvmTargets{'x86-64'}  = { label => '64-bit X86: EM64T and AMD64' };
+$llvmTargets{'llvm'} = { label => 'LLVM assembly' };
+$llvmTargets{'cpp'}  = { label => 'LLVM C++ API code' };
+my %targetLabels = map { $_ => $llvmTargets{$_}->{'label'} } keys %llvmTargets;
+sub llvmTargetsSortedByLabel {
+  $llvmTargets{$a}->{'label'} cmp $llvmTargets{$b}->{'label'};
+}
+
+my @sortedTargets = sort llvmTargetsSortedByLabel keys %llvmTargets;
+
 print $c->start_multipart_form( 'POST', $FORM_URL );
 
 my $source = $c->param('source');
@@ -216,16 +228,19 @@
 
 print "<center><h3>Output Options</h3></center>";
 
+print "Target: ",
+  $c->popup_menu(
+    -name    => 'target',
+    -default => 'llvm',
+    -values => \@sortedTargets,
+    -labels => \%targetLabels
+  ), ' <a href="DemoInfo.html#target">?</a><p>';
+
 print $c->checkbox(
     -name => 'showbcanalysis',
     -label => 'Show detailed bytecode analysis'
   ),' <a href="DemoInfo.html#bcanalyzer">?</a><br>';
 
-print $c->checkbox(
-    -name => 'showllvm2cpp',
-    -label => 'Show LLVM C++ API code'
-  ), ' <a href="DemoInfo.html#llvm2cpp">?</a>';
-
 print "</td></tr></table>";
 
 print "<center>", $c->submit(-value=> 'Compile Source Code'), 
@@ -245,9 +260,15 @@
     $sanitycheckfail .= ' llvm-dis'
       if `llvm-dis --help 2>&1` !~ /ll disassembler/;
 
+    $sanitycheckfail .= ' clang'
+      if `clang --help 2>&1` !~ /clang "gcc-compatible" driver/;
+
     $sanitycheckfail .= ' llvm-ld'
       if `llvm-ld --help 2>&1` !~ /llvm linker/;
 
+    $sanitycheckfail .= ' llc'
+      if `llc --help 2>&1` !~ /llvm system compiler/;
+
     $sanitycheckfail .= ' llvm-bcanalyzer'
       if `llvm-bcanalyzer --help 2>&1` !~ /bcanalyzer/;
     $sanitycheckfail .= ' clang'
@@ -294,31 +315,23 @@
 }
 
 my %suffixes = (
-    'Java'             => '.java',
-    'JO99'             => '.jo9',
     'C'                => '.c',
     'C++'              => '.cc',
-    'Fortran'          => '.f90',
+    'Objective-C'      => '.m',
+    'Objective-C++'    => '.mm',
     'preprocessed C'   => '.i',
     'preprocessed C++' => '.ii'
 );
 my %languages = (
-    '.jo9'  => 'JO99',
-    '.java' => 'Java',
     '.c'    => 'C',
     '.i'    => 'preprocessed C',
     '.ii'   => 'preprocessed C++',
     '.cc'   => 'C++',
     '.cpp'  => 'C++',
-    '.f'    => 'Fortran',
-    '.f90'  => 'Fortran'
 );
 my %language_options = (
-    'Java'             => '',
-    'JO99'             => '',
     'C'                => '',
     'C++'              => '',
-    'Fortran'          => '',
     'preprocessed C'   => '',
     'preprocessed C++' => ''
 );
@@ -346,6 +359,14 @@
 }
 
 if ($c->param && $source) {
+    # Since we inject target name in command line tool (llc), we need to
+    # validate it properly. Check if chosen target is an known valid target.
+    my $target = $c->param('target');
+    my $targetHTML = $c->escapeHTML($target);
+    barf(
+      "Unknown target $targetHTML. Please choose another one."
+    ) unless exists $llvmTargets{$target};
+
     print $c->hr;
     my $extension = $suffixes{ $c->param('language') };
     barf "Unknown language; can't compile\n" unless $extension;
@@ -406,13 +427,25 @@
 
     print " Bytecode size is ", -s $bytecodeFile, " bytes.\n";
 
-    my $disassemblyFile = getname(".ll");
-    try_run( "llvm-dis",
-        "llvm-dis -o=$disassemblyFile $bytecodeFile > $outputFile 2>&1",
-        $outputFile );
+    my $target = $c->param('target');
+    my $targetLabel = $llvmTargets{$target}->{'label'};
+
+    my $disassemblyFile;
+    if ( $target eq 'llvm' ) {
+        $disassemblyFile = getname(".ll");
+        try_run( "llvm-dis",
+            "llvm-dis -o=$disassemblyFile $bytecodeFile > $outputFile 2>&1",
+            $outputFile );
+    } else {
+        $disassemblyFile = getname(".s");
+        my $options = ( $c->param('optlevel') eq "None" ) ? "-O0" : "-O3";
+        try_run( "llc",
+            "llc -march=$target -asm-verbose $options -o=$disassemblyFile $bytecodeFile > $outputFile 2>&1",
+            $outputFile );
+    }
 
     if ( $c->param('cxxdemangle') ) {
-        print " Demangling disassembler output.\n";
+        print " Demangling target output.\n";
         my $tmpFile = getname(".ll");
         system("c++filt < $disassemblyFile > $tmpFile 2>&1");
         system("mv $tmpFile $disassemblyFile");
@@ -420,12 +453,17 @@
 
     my ( $UnhilightedResult, $HtmlResult );
     if ( -s $disassemblyFile ) {
+        my $programName = ( $target eq 'llvm' ) ? 'disassembler' : 'static compiler';
         ( $UnhilightedResult, $HtmlResult ) =
-          dumpFile( "Output from LLVM disassembler", $disassemblyFile );
-        print syntaxHighlightLLVM($HtmlResult);
+          dumpFile( "Output from llvm $programName targeting $targetLabel", $disassemblyFile );
+        if ( $target eq 'llvm' ) {
+            $HtmlResult = syntaxHighlightLLVM($HtmlResult);
+        }
+        # It would be nice to support highlighting of other assembly files.
+        print $HtmlResult;
     }
     else {
-        print "<p>Hmm, that's weird, llvm-dis didn't produce any output.</p>\n";
+        print "<p>Hmm, that's weird, llvm-dis/llc didn't produce any output.</p>\n";
     }
 
     if ( $c->param('showbcanalysis') ) {
@@ -433,11 +471,6 @@
       try_run( "llvm-bcanalyzer", "llvm-bcanalyzer $bytecodeFile > $analFile 2>&1", 
         $analFile);
     }
-    if ($c->param('showllvm2cpp') ) {
-      my $l2cppFile = getname(".l2cpp");
-      try_run("llvm2cpp","llc -march=cpp $bytecodeFile -o $l2cppFile 2>&1",
-        $l2cppFile);
-    }
 
     # Get the source presented by the user to CGI, convert newline sequences to simple \n.
     my $actualsrc = $c->param('source');





More information about the llvm-commits mailing list