xref: /openssl/crypto/perlasm/x86_64-support.pl (revision a6ed19dc)
1#! /usr/bin/env perl
2# Copyright 2020 The OpenSSL Project Authors. All Rights Reserved.
3#
4# Licensed under the Apache License 2.0 (the "License").  You may not use
5# this file except in compliance with the License.  You can obtain a copy
6# in the file LICENSE in the source distribution or at
7# https://www.openssl.org/source/license.html
8
9
10package x86_64support;
11
12# require "x86_64-support.pl";
13# $ptr_size=&pointer_size($flavour);
14# $ptr_reg=&pointer_register($flavour,$reg);
15
16sub ::pointer_size
17{
18    my($flavour)=@_;
19    my $ptr_size=8; $ptr_size=4 if ($flavour eq "elf32");
20    return $ptr_size;
21}
22
23sub ::pointer_register
24{
25    my($flavour,$reg)=@_;
26    if ($flavour eq "elf32") {
27	if ($reg eq "%rax") {
28	    return "%eax";
29	} elsif ($reg eq "%rbx") {
30	    return "%ebx";
31	} elsif ($reg eq "%rcx") {
32	    return "%ecx";
33	} elsif ($reg eq "%rdx") {
34	    return "%edx";
35	} elsif ($reg eq "%rdi") {
36	    return "%edi";
37	} elsif ($reg eq "%rsi") {
38	    return "%esi";
39	} elsif ($reg eq "%rbp") {
40	    return "%ebp";
41	} elsif ($reg eq "%rsp") {
42	    return "%esp";
43	} else {
44	    return $reg."d";
45	}
46    } else {
47	return $reg;
48    }
49}
50
511;
52