Re: [pcre-dev] [PATCH] JIT support with Intel compiler, old…

Page principale
Supprimer ce message
Auteur: Daniel Richard G
Date:  
À: Zoltán Herczeg
CC: pcre-dev
Sujet: Re: [pcre-dev] [PATCH] JIT support with Intel compiler, older Solaris
On Thu, 15 Nov 2012, Zoltán Herczeg wrote:

> Hi Daniel,
>
>> Only problem is, it's not clear how the assembly should refer to local
>> variables ("from" and "to"). I was reviewing this article...
>
> I may misunderstand something here, but I thought you target sparc not
> x86.


Yes; the document is interesting in that it describes the limitations of
the Solaris compiler's inline-assembly support, which is the same
regardless of architecture.

>> Why not provide an Intel-syntax equivalent of the AT&T assembly instead
>> of an error? There may be other 64-bit compilers that aren't handled by
>> the above cases.
>
> It would be a speculative fix, which may not work.


It would be easy enough to test---just disable the cpp case that uses
__cpuid().

> Perhaps some functions can reveal how it works.
>
> int test(int a, int b, char* c) {
> retrun a + b + strlen(c);
> }
>
> Could you try this with various calling conventions and send me the
> assembly?


Attached is the C source file I used, and an assembly file generated by
"icc -g -no-gcc -S".

An interesting discovery: Setting a calling convention with
__attribute__(()) has no effect in ICC (and this is true even if I drop
-no-gcc). Whether I specify cdecl, fastcall, or stdcall, the assembler
output is identical. As far as I can tell from the Intel docs, they
consider the whole notion of different calling conventions to exist only
on Windows.


--Daniel


--
Daniel Richard G. || danielg@??? || Software Developer
Teragram Linguistic Technologies (a division of SAS)
http://www.teragram.com/#include <string.h>

int zoltan_test(int a, int b, char* c)
{
    return a + b + strlen(c);
}

    .section .text
.LNDBG_TX:
# -- Machine type PW
# mark_description "Intel(R) C++ Compiler for applications running on IA-32, Version 11.1    Build 20100203 %s";
# mark_description "-long_double -g -no-gcc -S";
    .file "zoltan.c"
    .text
..TXTST0:
# -- Begin  zoltan_test
# mark_begin;
       .align    2,0x90
    .globl zoltan_test
zoltan_test:
# parameter 1(a): 8 + %ebp
# parameter 2(b): 12 + %ebp
# parameter 3(c): 16 + %ebp
..B1.1:                         # Preds ..B1.0
..___tag_value_zoltan_test.2:                                   #
..LN1:
  .file   1 "zoltan.c"
   .loc    1  4  is_stmt 1
        pushl     %ebp                                          #4.1
        movl      %esp, %ebp                                    #4.1
..___tag_value_zoltan_test.3:                                   #
        pushl     %esi                                          #4.1
..LN3:
   .loc    1  5  is_stmt 1
        pushl     %eax                                          #5.17
..LN5:
        movl      16(%ebp), %eax                                #5.24
        movl      %eax, (%esp)                                  #5.24
..LN7:
        call      strlen                                        #5.17
                                # LOE eax
..B1.5:                         # Preds ..B1.1
        popl      %ecx                                          #5.17
        movl      %eax, -4(%ebp)                                #5.17
                                # LOE
..B1.2:                         # Preds ..B1.5
..LN9:
        movl      12(%ebp), %eax                                #5.13
        addl      8(%ebp), %eax                                 #5.13
..LN11:
        addl      -4(%ebp), %eax                                #5.17
        leave                                                   #5.17
..___tag_value_zoltan_test.7:                                   #
        ret                                                     #5.17
        .align    2,0x90
..___tag_value_zoltan_test.9:                                   #
                                # LOE
# mark_end;
    .type    zoltan_test,@function
    .size    zoltan_test,.-zoltan_test
.LNzoltan_test:
    .data
# -- End  zoltan_test
    .data
    .section .note.GNU-stack, ""
// -- Begin DWARF2 SEGMENT .debug_info
    .section .debug_info
.debug_info_seg:
    .align 1
    .4byte 0x0000012a
    .2byte 0x0002
    .4byte .debug_abbrev_seg
    .byte 0x04
//    DW_TAG_compile_unit:
    .byte 0x01
//    DW_AT_comp_dir:
    .8byte 0x6e752e65672f722f
    .8byte 0x6f632e7361732e78
    .8byte 0x6f762f6c6f762f6d
    .8byte 0x3132752f3031326c
    .8byte 0x2f7a656d6f67642f
    .8byte 0x332e382d65726370
    .4byte 0x43522d32
    .2byte 0x0031
//    DW_AT_language:
    .byte 0x01
//    DW_AT_name:
    .8byte 0x632e6e61746c6f7a
    .byte 0x00
//    DW_AT_producer:
    .8byte 0x2952286c65746e49
    .8byte 0x6d6f43202b2b4320
    .8byte 0x6f662072656c6970
    .8byte 0x63696c7070612072
    .8byte 0x7220736e6f697461
    .8byte 0x6f20676e696e6e75
    .8byte 0x2c32332d4149206e
    .8byte 0x6e6f697372655620
    .8byte 0x202020312e313120
    .8byte 0x3220646c69754220
    .8byte 0x2033303230303130
    .8byte 0x65786946200a7325
    .8byte 0x7365676e61522073
    .8byte 0x65766974616c6552
    .2byte 0x000a
//    DW_AT_stmt_list:
    .4byte .debug_line_seg
//    DW_TAG_base_type:
    .byte 0x02
//    DW_AT_byte_size:
    .byte 0x04
//    DW_AT_encoding:
    .byte 0x05
//    DW_AT_name:
    .4byte 0x00746e69
//    DW_TAG_subprogram:
    .byte 0x03
//    DW_AT_decl_line:
    .byte 0x03
//    DW_AT_decl_column:
    .byte 0x05
//    DW_AT_decl_file:
    .byte 0x01
//    DW_AT_inline:
    .byte 0x00
//    DW_AT_accessibility:
    .byte 0x01
//    DW_AT_type:
    .4byte 0x000000c2
//    DW_AT_prototyped:
    .byte 0x01
//    DW_AT_name:
    .8byte 0x745f6e61746c6f7a
    .4byte 0x00747365
    .8byte 0x745f6e61746c6f7a
    .4byte 0x00747365
//    DW_AT_low_pc:
    .4byte zoltan_test
//    DW_AT_high_pc:
    .4byte .LNzoltan_test
//    DW_AT_external:
    .byte 0x01
//    DW_TAG_formal_parameter:
    .byte 0x04
//    DW_AT_decl_line:
    .byte 0x03
//    DW_AT_decl_column:
    .byte 0x15
//    DW_AT_decl_file:
    .byte 0x01
//    DW_AT_type:
    .4byte 0x000000c2
//    DW_AT_name:
    .2byte 0x0061
//    DW_AT_location:
    .2byte 0x7502
    .byte 0x08
//    DW_TAG_formal_parameter:
    .byte 0x04
//    DW_AT_decl_line:
    .byte 0x03
//    DW_AT_decl_column:
    .byte 0x1c
//    DW_AT_decl_file:
    .byte 0x01
//    DW_AT_type:
    .4byte 0x000000c2
//    DW_AT_name:
    .2byte 0x0062
//    DW_AT_location:
    .2byte 0x7502
    .byte 0x0c
//    DW_TAG_formal_parameter:
    .byte 0x04
//    DW_AT_decl_line:
    .byte 0x03
//    DW_AT_decl_column:
    .byte 0x25
//    DW_AT_decl_file:
    .byte 0x01
//    DW_AT_type:
    .4byte 0x0000011d
//    DW_AT_name:
    .2byte 0x0063
//    DW_AT_location:
    .2byte 0x7502
    .byte 0x10
    .byte 0x00
//    DW_TAG_pointer_type:
    .byte 0x05
//    DW_AT_type:
    .4byte 0x00000122
//    DW_TAG_base_type:
    .byte 0x02
//    DW_AT_byte_size:
    .byte 0x01
//    DW_AT_encoding:
    .byte 0x06
//    DW_AT_name:
    .4byte 0x72616863
    .byte 0x00
    .byte 0x00
    .byte 0x00
    .byte 0x00
    .byte 0x00
// -- Begin DWARF2 SEGMENT .debug_line
    .section .debug_line
.debug_line_seg:
    .align 1
// -- Begin DWARF2 SEGMENT .debug_abbrev
    .section .debug_abbrev
.debug_abbrev_seg:
    .align 1
    .byte 0x01
    .byte 0x11
    .byte 0x01
    .byte 0x1b
    .byte 0x08
    .byte 0x13
    .byte 0x0b
    .byte 0x03
    .byte 0x08
    .byte 0x25
    .byte 0x08
    .byte 0x10
    .byte 0x06
    .2byte 0x0000
    .byte 0x02
    .byte 0x24
    .byte 0x00
    .byte 0x0b
    .byte 0x0b
    .byte 0x3e
    .byte 0x0b
    .byte 0x03
    .byte 0x08
    .2byte 0x0000
    .byte 0x03
    .byte 0x2e
    .byte 0x01
    .byte 0x3b
    .byte 0x0b
    .byte 0x39
    .byte 0x0b
    .byte 0x3a
    .byte 0x0b
    .byte 0x20
    .byte 0x0b
    .byte 0x32
    .byte 0x0b
    .byte 0x49
    .byte 0x13
    .byte 0x27
    .byte 0x0c
    .byte 0x03
    .byte 0x08
    .2byte 0x4087
    .byte 0x08
    .byte 0x11
    .byte 0x01
    .byte 0x12
    .byte 0x01
    .byte 0x3f
    .byte 0x0c
    .2byte 0x0000
    .byte 0x04
    .byte 0x05
    .byte 0x00
    .byte 0x3b
    .byte 0x0b
    .byte 0x39
    .byte 0x0b
    .byte 0x3a
    .byte 0x0b
    .byte 0x49
    .byte 0x13
    .byte 0x03
    .byte 0x08
    .byte 0x02
    .byte 0x0a
    .2byte 0x0000
    .byte 0x05
    .byte 0x0f
    .byte 0x00
    .byte 0x49
    .byte 0x13
    .2byte 0x0000
    .byte 0x00
// -- Begin DWARF2 SEGMENT .debug_frame
    .section .debug_frame
.debug_frame_seg:
    .align 1
    .4byte 0x00000010
    .4byte 0xffffffff
    .byte 0x01
    .byte 0x00
    .byte 0x01
    .byte 0x7c
    .byte 0x08
    .4byte 0x8804040c
    .byte 0x01
    .2byte 0x0000
    .4byte 0x00000024
    .4byte .debug_frame_seg
    .4byte ..___tag_value_zoltan_test.2
    .4byte ..___tag_value_zoltan_test.9-..___tag_value_zoltan_test.2
    .byte 0x04
    .4byte 0x00000000
    .byte 0x04
    .4byte ..___tag_value_zoltan_test.3-..___tag_value_zoltan_test.2
    .byte 0x0c
    .2byte 0x0805
    .byte 0x85
    .byte 0x02
    .byte 0x04
    .4byte ..___tag_value_zoltan_test.7-..___tag_value_zoltan_test.3
    .byte 0x09
    .2byte 0x0505
    .byte 0x00
    .section .text
.LNDBG_TXe:
# End