X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;ds=sidebyside;f=ir%2Fbe%2Fbeemitter_binary.c;h=e7f8491a63e95024fa5b8a040b11d65f60a9d90d;hb=46b1210ed70f149727d212d7bae741ac0ed96028;hp=e9291e68025217d0a0b113d125ab4e9fe7431410;hpb=09b33db929514c565b37e1b15151c56bf381a9df;p=libfirm diff --git a/ir/be/beemitter_binary.c b/ir/be/beemitter_binary.c index e9291e680..e7f8491a6 100644 --- a/ir/be/beemitter_binary.c +++ b/ir/be/beemitter_binary.c @@ -1,20 +1,6 @@ /* - * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. - * * This file is part of libFirm. - * - * This file may be distributed and/or modified under the terms of the - * GNU General Public License version 2 as published by the Free Software - * Foundation and appearing in the file LICENSE.GPL included in the - * packaging of this file. - * - * Licensees holding valid libFirm Professional Edition licenses may use - * this file in accordance with the libFirm Commercial License. - * Agreement provided with the Software. - * - * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE - * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. + * Copyright (C) 2012 University of Karlsruhe. */ /** @@ -22,7 +8,6 @@ * @brief Interface for machine code output * @author Matthias Braun * @date 12.03.2007 - * @version $Id$ */ #include "config.h" @@ -32,6 +17,7 @@ #include "beemitter_binary.h" #include "obst.h" #include "pdeq.h" +#include "error.h" static code_fragment_t *first_fragment; static code_fragment_t *last_fragment; @@ -43,8 +29,8 @@ struct obstack code_fragment_obst; be_emit(8/16/32/entity) call!) */ code_fragment_t *be_get_current_fragment(void) { + code_fragment_t *fragment = (code_fragment_t*)obstack_base(&code_fragment_obst); assert(obstack_object_size(&code_fragment_obst) >= sizeof(code_fragment_t)); - code_fragment_t *fragment = obstack_base(&code_fragment_obst); assert(fragment->magic == CODE_FRAGMENT_MAGIC); return fragment; @@ -60,7 +46,7 @@ static void alloc_fragment(void) assert(obstack_object_size(&code_fragment_obst) == 0); obstack_blank(&code_fragment_obst, sizeof(*fragment)); - fragment = obstack_base(&code_fragment_obst); + fragment = (code_fragment_t*)obstack_base(&code_fragment_obst); memset(fragment, 0, sizeof(*fragment)); #ifndef NDEBUG fragment->magic = CODE_FRAGMENT_MAGIC; @@ -106,7 +92,7 @@ static void emit(FILE *file, const unsigned char *buffer, size_t len) size_t i2; fputs("\t.byte ", file); for (i2 = i; i2 < i + 30 && i2 < len; ++i2) { - fprintf(file, "0x%02X", buffer[i2]); + fprintf(file, "0x%02X", (unsigned)buffer[i2]); } i = i2; fputs("\n", file); @@ -176,6 +162,16 @@ static void determine_offsets(const binary_emiter_interface_t *interface) } while (changed); } +void be_emit_entity(ir_entity *entity, bool entity_sign, int offset, + bool is_relative) +{ + (void) entity; + (void) entity_sign; + (void) offset; + (void) is_relative; + panic("not implemented yet"); +} + void be_emit_code(FILE *output, const binary_emiter_interface_t *interface) { unsigned offset; @@ -192,14 +188,15 @@ void be_emit_code(FILE *output, const binary_emiter_interface_t *interface) for (fragment = first_fragment; fragment != NULL; fragment = fragment->next) { unsigned char *jmpbuffer; + unsigned nops; /* assure alignment by emitting nops */ assert(fragment->offset >= offset); - unsigned nops = fragment->offset - offset; + nops = fragment->offset - offset; if (nops > 0) { - unsigned char *nopbuffer = obstack_alloc(&code_fragment_obst, nops); - interface->create_nops(nopbuffer, nops); - emit(output, nopbuffer, nops); + unsigned char *nopbuffer = (unsigned char*)obstack_alloc(&code_fragment_obst, nops); + interface->create_nops(nopbuffer, nops); + emit(output, nopbuffer, nops); offset = fragment->offset; obstack_free(&code_fragment_obst, nopbuffer); } @@ -209,7 +206,7 @@ void be_emit_code(FILE *output, const binary_emiter_interface_t *interface) offset += fragment->len; /* emit the jump */ - jmpbuffer = obstack_alloc(&code_fragment_obst, fragment->jumpsize_min); + jmpbuffer = (unsigned char*)obstack_alloc(&code_fragment_obst, fragment->jumpsize_min); interface->emit_jump(fragment, jmpbuffer); emit(output, jmpbuffer, fragment->jumpsize_min); offset += fragment->jumpsize_min;