2 # Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
7 from driver_env import env
8 from driver_log import Log
15 'MC_FLAGS' : '-assemble -filetype=obj ${MC_FLAGS_%ARCH%}',
16 'MC_FLAGS_ARM' : ('-arch=arm -triple=armv7a-nacl -mcpu=cortex-a9 ' +
18 'MC_FLAGS_X8632' : '-arch=x86 -triple=i686-nacl',
19 'MC_FLAGS_X8664' : '-arch=x86-64 -triple=x86_64-nacl',
20 'MC_FLAGS_MIPS32': '-arch=mipsel -triple=mipsel-nacl',
21 'MC_FLAGS_ARM_NONSFI': ('-arch=arm -triple=armv7a -mcpu=cortex-a9 '
23 'MC_FLAGS_X8632_NONSFI': '-arch=x86 -triple=i686',
25 'RUN_LLVM_AS' : '${LLVM_AS} ${input} -o ${output}',
26 'RUN_LLVM_MC' : '${LLVM_MC} ${MC_FLAGS} ${input} -o ${output}',
29 VERSION_STR = """Portable Native Client assembler
31 GNU assembler version 2.21.51 (pnacl-pc-nacl) using BFD version (GNU Binutils) 2.21.51.20110525
32 Low Level Virtual Machine (http://llvm.org/)
35 def DumpVersionDebug():
36 sys.stderr.write(VERSION_STR)
38 def DumpVersionAndExit():
39 sys.stdout.write(VERSION_STR)
40 driver_tools.DriverExit(0)
43 ( '-o(.+)', "env.set('OUTPUT', pathtools.normalize($0))"),
44 ( ('-o', '(.+)'), "env.set('OUTPUT', pathtools.normalize($0))"),
46 ( '-v', DumpVersionDebug),
47 ( '--version', DumpVersionAndExit),
49 # Ignore these assembler flags
51 ( ('(--traditional-format)', '.*'), ""),
56 ( '(--fatal-warnings)', ""),
61 ( '(-.+)', driver_tools.UnrecognizedOption),
63 # Unmatched parameters should be treated as
64 # assembly inputs by the "as" incarnation.
65 ( '(-)', "env.append('INPUTS', $0)"),
66 ( '(.*)', "env.append('INPUTS', pathtools.normalize($0))"),
71 driver_tools.ParseArgs(argv, ASPatterns)
72 arch = driver_tools.GetArch()
74 inputs = env.get('INPUTS')
75 output = env.getone('OUTPUT')
77 for path in inputs + [output]:
78 driver_tools.CheckPathLength(path)
80 num_inputs = len(inputs)
82 Log.Fatal('Expecting exactly one input file')
99 env.set('input', the_input)
100 env.set('output', output)
102 if output_type == 'po':
104 driver_tools.Run("${RUN_LLVM_AS}")
107 driver_tools.Run("${RUN_LLVM_MC}")
109 # only reached in case of no errors
114 LLVM Assembler for PNaCl
115 Transform LLVM assembly (.ll) to LLVM bitcode.
117 Usage: pnacl-as [options] <input .ll file> -o <output.po>
120 -o <file> Output to file
121 --version Display version information
122 -help | -h Output this help.