Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Side by Side Diff: third_party/yasm/patched-yasm/modules/parsers/gas/gas-parse-intel.c

Issue 6170009: Update our yasm copy to yasm 1.1.0 (Part 1: yasm side)... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * GAS-compatible parser Intel syntax support
3 *
4 * Copyright (C) 2010 Alexei Svitkine
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of the author nor the names of other contributors
15 * may be used to endorse or promote products derived from this
16 * software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS''
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 */
30 #include <util.h>
31 RCSID("$Id: gas-parse-intel.c 2279 2010-01-19 07:57:43Z peter $");
32
33 #include <libyasm.h>
34
35 #include "modules/parsers/gas/gas-parser.h"
36 #include "modules/parsers/nasm/nasm-parser-struct.h"
37
38 extern yasm_bytecode *gas_intel_syntax_parse_instr(yasm_parser_nasm *parser_nasm , unsigned char *instr);
39
40 #define SET_FIELDS(to, from) \
41 (to)->object = (from)->object; \
42 (to)->locallabel_base = (from)->locallabel_base; \
43 (to)->locallabel_base_len = (from)->locallabel_base_len; \
44 (to)->preproc = (from)->preproc; \
45 (to)->errwarns = (from)->errwarns; \
46 (to)->linemap = (from)->linemap; \
47 (to)->prev_bc = (from)->prev_bc;
48
49 yasm_bytecode *parse_instr_intel(yasm_parser_gas *parser_gas)
50 {
51 char *stok, *slim;
52 unsigned char *line;
53 size_t length;
54
55 yasm_parser_nasm parser_nasm;
56 yasm_bytecode *bc;
57
58 memset(&parser_nasm, 0, sizeof(parser_nasm));
59
60 yasm_arch_set_var(parser_gas->object->arch, "gas_intel_mode", 1);
61 SET_FIELDS(&parser_nasm, parser_gas);
62 parser_nasm.masm = 1;
63
64 stok = (char *) parser_gas->s.tok;
65 slim = (char *) parser_gas->s.lim;
66 length = 0;
67 while (&stok[length] < slim && stok[length] != '\n') {
68 length++;
69 }
70
71 if (&stok[length] == slim && parser_gas->line) {
72 line = yasm_xmalloc(length + parser_gas->lineleft + 1);
73 memcpy(line, parser_gas->s.tok, length);
74 memcpy(line + length, parser_gas->linepos, parser_gas->lineleft);
75 length += parser_gas->lineleft;
76 if (line[length - 1] == '\n') length--;
77 } else {
78 line = yasm_xmalloc(length + 1);
79 memcpy(line, parser_gas->s.tok, length);
80 }
81 line[length] = '\0';
82
83 bc = gas_intel_syntax_parse_instr(&parser_nasm, line);
84
85 SET_FIELDS(parser_gas, &parser_nasm);
86 yasm_arch_set_var(parser_gas->object->arch, "gas_intel_mode", 0);
87
88 yasm_xfree(line);
89
90 return bc;
91 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698