This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] s390 support for tpf os
- From: Eric Christopher <echristo at redhat dot com>
- To: Ulrich Weigand <weigand at immd1 dot informatik dot uni-erlangen dot de>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: 21 Jul 2003 16:43:09 -0700
- Subject: Re: [patch] s390 support for tpf os
- References: <200306151531.RAA25484@faui11.informatik.uni-erlangen.de>
> Independently of whether we have the LLGT(R) pattern or whether
> we use the AND instruction, Richard's suggestion appears reasonable.
> Could you try whether this works as well (I don't have TPF test cases)?
Alright. Done this way, retested (and a good thing since I'd missed
something). Here's the final patch again.
OK?
-eric
--
Eric Christopher <echristo@redhat.com>
2003-07-21 Eric Christopher <echristo@redhat.com>
* config/s390.c (s390_valid_pointer_mode): New.
(TARGET_VALID_POINTER_MODE): Use.
(s390_emit_prologue): Add tpf profiling hooks.
(s390_emit_epilogue): Ditto.
* config/s390.h (MASK_TPF): New.
(TARGET_TPF): Use.
(POINTERS_EXTEND_UNSIGNED): Define.
* config/s390.md (ptr_extend): New pattern.
Index: s390.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/s390/s390.c,v
retrieving revision 1.104
diff -u -p -w -r1.104 s390.c
--- s390.c 19 Jul 2003 16:06:52 -0000 1.104
+++ s390.c 21 Jul 2003 22:32:02 -0000
@@ -76,7 +76,7 @@ static int s390_sched_reorder2 PARAMS ((
static bool s390_rtx_costs PARAMS ((rtx, int, int, int *));
static int s390_address_cost PARAMS ((rtx));
static void s390_reorg PARAMS ((void));
-
+static bool s390_valid_pointer_mode PARAMS ((enum machine_mode));
#undef TARGET_ASM_ALIGNED_HI_OP
#define TARGET_ASM_ALIGNED_HI_OP "\t.word\t"
@@ -138,6 +138,9 @@ static void s390_reorg PARAMS ((void));
#undef TARGET_MACHINE_DEPENDENT_REORG
#define TARGET_MACHINE_DEPENDENT_REORG s390_reorg
+#undef TARGET_VALID_POINTER_MODE
+#define TARGET_VALID_POINTER_MODE s390_valid_pointer_mode
+
struct gcc_target targetm = TARGET_INITIALIZER;
extern int reload_completed;
@@ -5515,11 +5518,13 @@ s390_emit_prologue ()
s390_frame_info ();
- /* Choose best register to use for temp use within prologue. */
+ /* Choose best register to use for temp use within prologue.
+ See below for why TPF must use the register 1. */
if (!current_function_is_leaf
&& !has_hard_reg_initial_val (Pmode, RETURN_REGNUM)
- && get_pool_size () < S390_POOL_CHUNK_MAX / 2)
+ && get_pool_size () < S390_POOL_CHUNK_MAX / 2
+ && !TARGET_TPF)
temp_reg = gen_rtx_REG (Pmode, RETURN_REGNUM);
else
temp_reg = gen_rtx_REG (Pmode, 1);
@@ -5671,6 +5676,28 @@ s390_emit_prologue ()
if (flag_pic && regs_ever_live[PIC_OFFSET_TABLE_REGNUM])
s390_load_got (true);
+
+ if (TARGET_TPF)
+ {
+ /* Generate a BAS instruction to serve as a function
+ entry intercept to facilitate the use of tracing
+ algorithms located at the branch target.
+
+ This must use register 1. */
+ rtx addr;
+ rtx unkn;
+ rtx link;
+
+ addr = GEN_INT (0xfe0);
+ unkn = CONST0_RTX (SImode);
+ link = gen_rtx_REG (Pmode, 1);
+
+ emit_call_insn (gen_call_exp (gen_rtx_MEM (QImode, addr), unkn, link));
+
+ /* Emit a blockage here so that all code
+ lies between the profiling mechanisms. */
+ emit_insn (gen_blockage ());
+ }
}
/* Expand the epilogue into a bunch of separate insns. */
@@ -5682,6 +5709,30 @@ s390_emit_epilogue ()
int area_bottom, area_top, offset = 0;
rtvec p;
+ if (TARGET_TPF)
+ {
+
+ /* Generate a BAS instruction to serve as a function
+ entry intercept to facilitate the use of tracing
+ algorithms located at the branch target.
+
+ This must use register 1. */
+
+ rtx addr;
+ rtx unkn;
+ rtx link;
+
+ addr = GEN_INT (0xfe6);
+ unkn = CONST0_RTX (SImode);
+ link = gen_rtx_REG (Pmode, 1);
+
+ /* Emit a blockage here so that all code
+ lies between the profiling mechanisms. */
+ emit_insn (gen_blockage ());
+
+ emit_call_insn (gen_call_exp (gen_rtx_MEM (QImode, addr), unkn, link));
+ }
+
/* Check whether to use frame or stack pointer for restore. */
frame_pointer = frame_pointer_needed ?
@@ -6248,6 +6299,7 @@ s390_va_arg (valist, type)
reg = gpr;
n_reg = (size + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
sav_ofs = 2 * UNITS_PER_WORD;
+
if (size < UNITS_PER_WORD)
sav_ofs += UNITS_PER_WORD - size;
@@ -6887,6 +6939,13 @@ s390_output_mi_thunk (file, thunk, delta
output_asm_insn (".long\t%3", op);
}
}
+}
+
+bool
+s390_valid_pointer_mode (mode)
+ enum machine_mode mode;
+{
+ return (mode == SImode || (TARGET_64BIT && mode == DImode));
}
/* How to allocate a 'struct machine_function'. */
Index: s390.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/s390/s390.h,v
retrieving revision 1.78
diff -u -p -w -r1.78 s390.h
--- s390.h 4 Jul 2003 22:28:58 -0000 1.78
+++ s390.h 21 Jul 2003 22:32:03 -0000
@@ -94,6 +94,7 @@ extern int target_flags;
#define MASK_64BIT 0x10
#define MASK_ZARCH 0x20
#define MASK_MVCLE 0x40
+#define MASK_TPF 0x80
#define TARGET_HARD_FLOAT (target_flags & MASK_HARD_FLOAT)
#define TARGET_SOFT_FLOAT (!(target_flags & MASK_HARD_FLOAT))
@@ -103,6 +104,7 @@ extern int target_flags;
#define TARGET_64BIT (target_flags & MASK_64BIT)
#define TARGET_ZARCH (target_flags & MASK_ZARCH)
#define TARGET_MVCLE (target_flags & MASK_MVCLE)
+#define TARGET_TPF (target_flags & MASK_TPF)
/* ??? Once this actually works, it could be made a runtime option. */
#define TARGET_IBM_FLOAT 0
@@ -129,6 +131,8 @@ extern int target_flags;
{ "esa", -32, N_("ESA/390 architecture")}, \
{ "mvcle", 64, N_("mvcle use")}, \
{ "no-mvcle", -64, N_("mvc&ex")}, \
+ { "tpf", 128, N_("enable tpf OS code")}, \
+ { "no-tpf", -128, N_("disable tpf OS code")}, \
{ "", TARGET_DEFAULT, 0 } }
#define TARGET_OPTIONS \
@@ -1103,6 +1107,9 @@ extern int s390_nr_constants;
between pointers and any other objects of this machine mode. */
#define Pmode ((enum machine_mode) (TARGET_64BIT ? DImode : SImode))
+/* This is -1 for "pointer mode" extend. See ptr_extend in s390.md. */
+#define POINTERS_EXTEND_UNSIGNED -1
+
/* A function address in a call instruction is a byte address (for
indexing purposes) so give the MEM rtx a byte's mode. */
#define FUNCTION_MODE QImode
Index: s390.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/s390/s390.md,v
retrieving revision 1.63
diff -u -p -w -r1.63 s390.md
--- s390.md 19 Jul 2003 16:06:52 -0000 1.63
+++ s390.md 21 Jul 2003 22:32:10 -0000
@@ -7197,3 +7197,24 @@
}
[(set_attr "op_type" "NN")
(set_attr "type" "larl")])
+
+;; Instruction definition to extend a 31-bit pointer into a 64-bit
+;; pointer. This is used for compatability.
+
+(define_expand "ptr_extend"
+ [(set (match_operand:DI 0 "register_operand" "=r")
+ (match_operand:SI 1 "register_operand" "r"))]
+ ""
+ "
+{
+ /*
+ emit_insn (gen_zero_extendsidi2 (operands[0], operands[1]));
+ emit_insn (gen_anddi3 (operands[0], operands[0], GEN_INT (0x7fffffff)));
+ */
+
+ emit_insn (gen_anddi3 (operands[0],
+ gen_lowpart (DImode, operands[1]),
+ GEN_INT (0x7fffffff)));
+
+ DONE;
+}")