i_mapper_log() added
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Tue, 13 Nov 2007 16:27:48 +0000 (16:27 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Tue, 13 Nov 2007 16:27:48 +0000 (16:27 +0000)
[r16523]

include/libfirm/lowering.h
ir/lower/lower_intrinsics.c

index f6f5a3c..007bfc2 100644 (file)
@@ -306,6 +306,19 @@ int i_mapper_pow(ir_node *call, void *ctx);
  */
 int i_mapper_exp(ir_node *call, void *ctx);
 
+#define i_mapper_exp2   i_mapper_exp
+#define i_mapper_exp10  i_mapper_exp
+
+/**
+ * A mapper for the floating point log(a): floattype log(floattype a);
+ *
+ * @return 0 if the log call was removed, 0 else.
+ */
+int i_mapper_log(ir_node *call, void *ctx);
+
+#define i_mapper_log2   i_mapper_log
+#define i_mapper_log10  i_mapper_log
+
 /**
  * A mapper for the floating point sin(a): floattype sin(floattype a);
  *
index da9ac04..0d606bd 100644 (file)
@@ -301,6 +301,23 @@ int i_mapper_exp(ir_node *call, void *ctx) {
        return 0;
 }
 
+/* A mapper for the floating point log. */
+int i_mapper_log(ir_node *call, void *ctx) {
+       ir_node *val  = get_Call_param(call, 0);
+       (void) ctx;
+
+       if (is_Const(val) && is_Const_one(val)) {
+               /* log(1.0) = 0.0 */
+               ir_node *block = get_nodes_block(call);
+               ir_mode *mode  = get_irn_mode(val);
+               ir_node *irn   = new_r_Const(current_ir_graph, block, mode, get_mode_null(mode));
+               ir_node *mem   = get_Call_mem(call);
+               replace_call(val, call, mem, NULL, NULL);
+               return 1;
+       }
+       return 0;
+}
+
 /* A mapper for the floating point sin. */
 int i_mapper_sin(ir_node *call, void *ctx) {
        ir_node *val  = get_Call_param(call, 0);